Back event

Sometimes in our applications we need to change the flow of execution.

Suppose we have a "wizard" inside our application, the user should not be able to go back to the different steps of the "wizard" as (s)he moves forward. In order to accomplish this, GeneXus provides a variety of events to manage the application flow, among which is the Back event.

Back Event is a system event which defines an action to be performed when the back button is pressed. It is commonly used to change back button behavior or prompt a confirm dialog before calling the previous panel.

Syntax

Event Back
        Event_code
EndEvent

Examples

  • Disable the back button

Event Back
EndEvent
  • Display a confirm dialog before calling the previous panel

Event Back
    Composite
      Confirm("Are you sure you want to return?") 
      return 
    EndComposite
EndEvent
  • Call a Panel for Smart Devices on Back

  • Event Back
         SDPanel.Call()
    EndEvent

Note: If you are trying to skip panels that had been already done on a wizard, it is recommended to use Call options = Replace on the caller, instead of calling a panel on the back event. With that you optimize the usage of the application stack, replacing old panels with new ones when navigating through the application.

Limitations

In iOS the only supported scenario is hiding the Back button, by leaving the Back Event empty.
This is because it is not possible to change the Back button behavior in iOS, and even if it were possible (like replacing the default button with a custom one that looks the same way), it is discouraged by the platform guidelines.

Considerations

How to get the default behavior in Back event  

In Back event, you are able to go back in two ways: with Return command or SDActions.Cancel() method. If the behavior you want to obtain is equivalent to not having the Back event, you have to use SDActions.Cancel() instead of Return.

Scope

Objects  Work With for Smart Devices objectPanel for Smart Devices
Languages .NET, Java, Ruby
Platforms Android, iOS

See also