Show TOC

Event Handler MethodsLocate this document in the navigation structure

Event handler methods are invoked when an event occurs. Method names starting with on are reserved for event handler methods.

For common events, such as click or keydown, it is sufficient to add a handler method. As SAPUI5 core automatically registers browser event handlers for these methods, they are called automatically. SAPUI5 core also fires events with a richer semantic meaning, so that control developers do not need to check so many keycodes, and so on.

These events are defined in and their names start with "sap". An example is the sapnext event, which is triggered by "arrow down" or "arrow right" (or "arrow left" in right-to-left mode). The sapnext event performs all checks that are required to check whether the user wants to navigate to the next item. The evt object that is passed to the handler method contains more information. These methods are private methods and must only be called by SAPUI5 core.

onclick: function(evt) {

     alert("Control " + this.getId() + " was clicked.");


  onsapnext: function(evt) {

     // navigate to next item, an arrow key was pressed