Mojo.Event

Namespace Detail

Holds functionality related to the UI Toolkit Events.

Summary

Method Summary


Detail

Mojo.Event.aboutToActivate

Generated before a scene is displayed. Allows widgets or scenes to delay the scene transition if needed.

Supported Widgets


Mojo.Event.activate

An activate event is generated when a scene is loaded.

Supported Widgets


Mojo.Event.back

This event is sent through the active commander chain when a back gesture is recognized (or the back key is pressed on the desktop).

It's currently generated by the stage assistant, which also responds to it in handleCommand(). If no other clients handle the event, then the stage assistant will do so by closing the current dialog or popping the current scene.

Custom Event Fields

Supported Widgets


Mojo.Event.command

A command event is generated when a menu item is selected.

Supported Widgets


Mojo.Event.commandEnable

Menu items that specify checkEnabled:true in the menu model cause the menu system to check their enable state before displaying them. This is useful for items in submenus and the appmenu, because they are not constantly displayed (like items in the command and view menus), meaning their enable state always appears correct when the menu is popped up. The command-enabled event is generated as part of menu updating. To check the enable state of a menu item, a command-enable event is sent through the commander chain. This event does not go through the DOM. If nothing in the commander chain calls preventDefault() on the event, the menu item will be enabled.

Supported Widgets


Mojo.Event.dragEnd

An up action following a Mojo.Event.dragStart event generates a dragEnd event.

Supported Widgets


Mojo.Event.dragging

Movement following the Mojo.Event.dragStart event generates dragging events.

Supported Widgets


Mojo.Event.dragStart

A down action followed by movement outsided of a system-defined radius generates a Mojo.Event.dragStart event. Usually, the Mojo.Event.dragStart event is handled by the scroller. However, any element that chooses to handle this event gets all subsequent drag events.

Supported Widgets


Mojo.Event.filter

Entering data in the filterbox generates a filter event after a client of default specified delay.

Supported Widgets


Mojo.Event.filterImmediate

Entering data in the filterbox generates a filter event as soon as a key is typed.

Supported Widgets


Mojo.Event.flick

Movement greater than a system-defined rate, between down and up events, generates a flick event.

Supported Widgets


Mojo.Event.forward

This event is sent through the active commander chain when a forward gesture is recognized

Supported Widgets


Mojo.Event.hold

A down movement lasting greater than a system-defined time interval and with movement within a limited radius generates a hold event. The hold event is associated with the Mojo.Event.hold event.

Supported Widgets


Mojo.Event.holdEnd

An up movement following a hold event generates a Mojo.Event.holdEnd event.

Supported Widgets


Mojo.Event.imageViewChanged

Sent from an ImageView widget when the current center image has been changed via a gesture.

Supported Widgets


Mojo.Event.keydown

Forwarded keydown event. Only supported on the currently active sceneElement or container.

Custom Event Fields

Supported Widgets


Mojo.Event.keypress

Forwarded keydown event. Only supported on the currently active sceneElement or container.

Custom Event Fields

Supported Widgets


Mojo.Event.keyup

Forwarded keyup event. Only supported on the currently active sceneElement or container.

Custom Event Fields

Supported Widgets


Mojo.Event.listAdd

This event is dispatched to the widget element when the special "Add" item at the end of the list is clicked. This item appears when the addItemLabel property is defined in the widget's attributes or model, and a custom event name is used to give applications an easy way to identify the expected behavior.

Custom Event Fields

Supported Widgets


Mojo.Event.listChange

This event is dispatched to the widget element when a list item is clicked. As with Mojo.Event.listTap, the app handler is responsible for sorting out which part of the list item changed if there are multiple options, and event.originalEvent.target should be the input element that changed.

Custom Event Fields

Supported Widgets


Mojo.Event.listDelete

This event is dispatched to the widget element when an item is deleted from the list. SceneAssistants will often listen for this event on List widgets, and should respond by deleting the given item from the model (and database, if any). If preventDefault() is called on the listDelete event, then the default deletion behavior in the list widget will not occur.

Custom Event Fields

Supported Widgets


Mojo.Event.listReorder

This event is dispatched to the widget element when an item is reordered. SceneAssistants will often listen for this event on List widgets, and should respond by reordering the given item model as indicated (and persist the changes to disk if appropriate).

Custom Event Fields

Supported Widgets


Mojo.Event.listTap

This event is dispatched to the widget element when there is a mojo-tap event on a list item. The app handler is responsible for sorting out which part of the list item was clicked if necessary, since that depends entirely on the template provided. It's useful to look at event.originalEvent.target. This is the target of the original click or change event that caused the higher level mojo event to be dispatched. It will be an input element containing the new value for a change event, or the item's sub-element that was actually clicked for a click event. For example:

listClickHandler: function(event) {
  // Only respond to clicks on the label element,
  // not the editable text field.
  if(event.originalEvent.target.tagName == "LABEL") {
      Mojo.Log.info(event.item.data +": "+event.item.definition);
  }
} 

Custom Event Fields

Supported Widgets


Mojo.Event.orientationChange

Sent by the scene controller on the scene element when the screen orientation changes. Contains an orientation property describing the orientation.


Mojo.Event.progressComplete

Sent when progress reaches 100%.

Supported Widgets


Mojo.Event.progressIconTap

Sent when the icon on the ProgressPill is tapped by the user.

Custom Event Fields

Supported Widgets


Mojo.Event.propertyChange

This event is dispatched to the widget element when property-editing widgets change values.

Custom Event Fields

Sometimes available:

Supported Widgets


Mojo.Event.scrollStarting

When contained in a scroller, down action followed by movement generates a scroll-starting event.

Supported Widgets


Mojo.Event.singleTap

A native down-and-up movement within a limited time interval and within a limited radius generates a single tap event.

It's sent when Mojo.handleSingleTap is called and has the following properties: x, y, shiftKey, ctrlKey, altKey, metaKey, timestamp.

Supported Widgets


Mojo.Event.sliderDragEnd

Sent when the draggable element on the Slider is dropped.

Supported Widgets


Mojo.Event.sliderDragStart

Sent when the draggable element on the Slider is picked up to be dragged.

Supported Widgets


Mojo.Event.stageActivate

A stageActivate event is generated when a stage becomes active and is potentially receiving the user's attention. For card stages, this is when the stage is maximized and fills the screen. The event is sent to the top scene, and bubbles up to the stage's document.

Supported Widgets


Mojo.Event.stageDeactivate

A stageDeactivate event is generated when a stage is no longer active and potentially receiving the user's attention. For card stages, this is when the stage is minimized.

The event is sent to the top scene, and bubbles up to the stage's document.

Supported Widgets


Mojo.Event.tap

A down-and-up movement within a limited time interval and within a limited radius generates a tap event.

Supported Widgets


Mojo.Event.webViewImageSaved

Sent in response to saving inline images.

Supported Widgets


Method Detail

Mojo.Event.listen(target, type{string}, handlerFunction, useCapture)

A wrapper around addEventListener that adds some parameter checking.

Parameters


Mojo.Event.listenForFocusChanges(node, handler)

This function can be used to listen for changes in the focused element inside the node.

A 'listener object' is returned which implements a stopListening() method. This can be called to permanently cancel the listener, removing its event listeners.

Parameters


Mojo.Event.listenForHoldEvent(node, downEvent, upEvent, handler, timeout)

This function can be used to listen for some kind of 'hold' event on a given node. This works by initiating a 'hold timer' when the appropriate 'down' event is received, and cancelling it if we see the 'up' event before it has expired. If the timer expires, then we call the given handler function with the initial 'down' event as the first argument.

A 'listener object' is returned which implements a stopListening() method. This can be called to permanently cancel the listener, removing its event listeners. Alternatively, if the handler function returns true, then the listener will be automatically stopped.

The implementation is somewhat tailored for key events:

Parameters


{Object} Mojo.Event.make(name{string}, details, optionalDocument, optionalBubbles, optionalCancel)

Utility routine used to create custom mojo events.

In addition to creating an event with the given name, the event is also extended such that an isDefaultPrevented() method is available.

Parameters

Returns


Mojo.Event.send(element, name{string}, mojoDetails, optionalBubbles, optionalCancel)

Like prototype's element.fire(), except that the event type is actually as specified (instead of always dataavailable), and the specified details are placed in the event object directly (instead of a memo subobject). If element is undefined, the new event will just be returned and not actually dispatched.

Parameters


Mojo.Event.sendKeyDownAndUpEvents(keyDescription, optionalDocument)

Function to create and send a key down and up event.

Parameters


Mojo.Event.sendKeyEvent(keyDescription, optionalEventType, optionalDocument)

Function to create and send a key event.

Parameters


Mojo.Event.stopListening(target, type{string}, handlerFunction, useCapture)

A wrapper around removeEventListener that adds some parameter checking.

Parameters