Mojo.Event

Namespace Detail

Holds functionality related to the UI Toolkit Events.

Summary
Field Name and Description
Mojo.Event.aboutToActivate
Mojo.Event.activate
Mojo.Event.back
Mojo.Event.command
Mojo.Event.commandEnable
Mojo.Event.dragEnd
Mojo.Event.dragging
Mojo.Event.dragStart
Mojo.Event.filter
Mojo.Event.filterImmediate
Mojo.Event.flick
Mojo.Event.forward
Mojo.Event.hold
Mojo.Event.holdEnd
Mojo.Event.imageViewChanged
Mojo.Event.keydown
Mojo.Event.keypress
Mojo.Event.keyup
Mojo.Event.listAdd
Mojo.Event.listChange
Mojo.Event.listDelete
Mojo.Event.listReorder
Mojo.Event.listTap
Mojo.Event.orientationChange
Mojo.Event.progressComplete
Mojo.Event.progressIconTap
Mojo.Event.propertyChange
Mojo.Event.scrollStarting
Mojo.Event.singleTap
Mojo.Event.sliderDragEnd
Mojo.Event.sliderDragStart
Mojo.Event.stageActivate
Mojo.Event.stageDeactivate
Mojo.Event.tap
Mojo.Event.webViewImageSaved
Method Summary
Method Name and Description
Mojo.Event.listen(target, type{string}, handlerFunction, useCapture)
Mojo.Event.listenForFocusChanges(node, handler)
Mojo.Event.listenForHoldEvent(node, downEvent, upEvent, handler, timeout)
Mojo.Event.make(name{string}, details, optionalDocument, optionalBubbles, optionaCancel)
Mojo.Event.send(element, name{string}, mojoDetails, optionalBubbles, optionaCancel)
Mojo.Event.sendKeyDownAndUpEvents(keyDescription, optionalDocument)
Mojo.Event.sendKeyEvent(keyDescription, optionalEventType, optionalDocument)
Mojo.Event.stopListening(target, type{string}, handlerFunction, useCapture)
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

Menuitems 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 & 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 menuitem, 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 menuitem 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

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 there 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 which 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.object.data +": "+event.object.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 - model: model associated with this progress pill.

Supported Widgets

Mojo.Event.propertyChange

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

Custom Event Fields

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:
target
target to observe
type{string}
type of the event to observe
handlerFunction
{Function} function to call when the event fires
useCapture
{Boolean} optional parameter that when true causes the event to be observed during the capture phase.
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 permanently cancel the listener, removing its event listeners.

Parameters:
node
- the node on which to listen for events.
handler
- Function to be called when focus changes, passing the newly focused element or null.
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 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: * Successive 'down' events do not reset the hold timer. * After calling the handler once, it will not be called again until after an 'up' event is received.

Parameters:
node
- the node on which to listen for events.
downEvent
- String, the type of event that should initiate the hold timer.
upEvent
- String, the type of event that should cancel the hold timer.
handler
- Function to be called when the hold timer expires.
timeout
- Length of hold timer in seconds. Optional, defaults to 1.
{Object} Mojo.Event.make(name{string}, details, optionalDocument, optionalBubbles, optionaCancel)

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 a isDefaultPrevented() method is available.

Parameters:
name{string}
is the name of the event, visible in event.type.
details
{string} is a hash of custom event properties to be copied to the event object.
optionalDocument
{HTML element} is a supplied element to target the event on; if not supplied, defaults to current active document
optionalBubbles
{Boolean} flag determining if the event's propogation behavior is to bubble; default is true
optionaCancel
{Boolean} flag determining if the event's default action may be prevented via the preventDefault( ) method; default is true
Returns:
{Object} This will return 'true' if any handler calls event.preventDefault().
Mojo.Event.send(element, name{string}, mojoDetails, optionalBubbles, optionaCancel)

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:
element
HTML element to dispatch the event on.
name{string}
is the name of the event, visible in event.type.
mojoDetails
{string} is a hash of custom event properties to be copied to the event object.
optionalBubbles
{Boolean} flag determining if the event's propogation behavior is to bubble; default is true
optionaCancel
{Boolean} flag determining if the event's default action may be prevented via the preventDefault( ) method; default is true
Mojo.Event.sendKeyDownAndUpEvents(keyDescription, optionalDocument)

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

Parameters:
keyDescription
key description for key, like "U+0009" for tab.
optionalDocument
{HTML element} is a supplied element to target the event on; if not supplied, defaults to current active document
Mojo.Event.sendKeyEvent(keyDescription, optionalEventType, optionalDocument)

Function to create and send a key event.

Parameters:
keyDescription
{String} key description for key, like "U+0009" for tab.
optionalEventType
{String} event type, defaults to 'keydown'.
optionalDocument
{HTML element} is a supplied element to target the event on; if not supplied, defaults to current active document
Mojo.Event.stopListening(target, type{string}, handlerFunction, useCapture)

A wrapper around removeEventListener that adds some parameter checking.

Parameters:
target
target to observe.
type{string}
type of the event that was being observed.
handlerFunction
{Function} function that was previously passed to listen.
useCapture
{Boolean} optional parameter that when true causes a capture phase listener to be removed.

Documentation generated by JsDoc Toolkit 2.1.1 on Thu Oct 29 2009 15:28:12 GMT-0700 (PDT)