Packagecom.yworks.canvas.input
Classpublic class ContextMenuInputMode
InheritanceContextMenuInputMode Inheritance AbstractConcurrentInputMode Inheritance AbstractInputMode Inheritance flash.events.EventDispatcher

An implementation of the IInputMode interface that allows to customize the context menu that is shown when the user clicks the right mouse button.

This input mode is intented for adding context menu items to the context menu just before the context menu is displayed. Therefore, all custom items are removed before the menuSelect event is dispatched. Custom context menu items can then be added in event handler functions for the menuSelect event.

Note that in an Adobe AIR application, no mouse events will be dispatched while a context menu is still open. Therefore, the coordinates of the CanvasContextMenuEvents dispatched by this input mode will only be updated while no context menu is visible.



Public Properties
 PropertyDefined by
 Inheritedcanvas : CanvasComponent
The canvas instance this mode is currently installed in or null
AbstractInputMode
 Inheritedcontroller : ConcurrencyController
Gets or injects the ConcurrencyController for this instance.
AbstractConcurrentInputMode
 Inheritedenabled : Boolean
Gets or sets the enabled state of this input mode.
AbstractConcurrentInputMode
 InheritedinputModeContext : IInputModeContext
The context instance this mode is currently installed in or null if this instance is not installed.
AbstractInputMode
 Inheritedinstalled : Boolean
Whether this mode is currently installed, i.e.
AbstractInputMode
  menu : ContextMenu
Gets or sets the menu to show.
ContextMenuInputMode
 InheritedpreferredCursor : Cursor
Gets or sets the cursor this mode would like to have displayed in the CanvasComponent.
AbstractConcurrentInputMode
Public Methods
 MethodDefined by
  
ContextMenuInputMode(menu:ContextMenu = null)
Creates a new instance using the provided menu.
ContextMenuInputMode
 Inherited
cancel():void
Releases the mutex if this input mode currently owns the mutex.
AbstractConcurrentInputMode
 Inherited
dispose():void
Disposes this input mode.
AbstractInputMode
  
install(context:IInputModeContext):void
Installs this mode in the canvas, registering the menu as the canvas' contextMenu.
ContextMenuInputMode
 Inherited
stop():Boolean
Returns true if this input mode doesn't own the mutex.
AbstractConcurrentInputMode
  
ContextMenuInputMode
Protected Methods
 MethodDefined by
 Inherited
canRequestMutex():Boolean
Determines whether this instance can request the InputMutex.
AbstractConcurrentInputMode
  
Creates an IInputModeContext for use with the next menuSelect event.
ContextMenuInputMode
  
createMenu():ContextMenu
Factory method that creates the initial menu.
ContextMenuInputMode
 Inherited
hasMutex():Boolean
Determines whether this instance owns the input mutex.
AbstractConcurrentInputMode
 Inherited
initialize():void
Performs one-time initialization of this instance.
AbstractInputMode
 Inherited
invalidate():void
Convenience method for subclass implementations that invalidates the canvasComponent this mode is currently installed in.
AbstractInputMode
 Inherited
onDisabled():void
Called when the enabled property changes to false.
AbstractConcurrentInputMode
 Inherited
onEnabled():void
Called when the enabled property changes to true.
AbstractConcurrentInputMode
 Inherited
Called when this instance obtains the InputMutex.
AbstractConcurrentInputMode
 Inherited
Called when this instance released the InputMutex.
AbstractConcurrentInputMode
 Inherited
onPreferredCursorChanged(oldValue:Cursor, newValue:Cursor):void
Called when the preferredCursor property changes.
AbstractConcurrentInputMode
 Inherited
releaseMutex():void
Releases the mutex that is currently owned by this instance.
AbstractConcurrentInputMode
 Inherited
requestMutex():void
Requests the InputMutex from the current controller.
AbstractConcurrentInputMode
Events
 EventSummaryDefined by
   Dispatched when the contextMenu is about to be shown ContextMenuInputMode
 Inherited Dispatched when the default cursor changed.AbstractConcurrentInputMode
Public Constants
 ConstantDefined by
 InheritedPREFERRED_CURSOR_CHANGED : String = "preferredCursorChanged"
[static]
AbstractConcurrentInputMode
Property detail
menuproperty
menu:ContextMenu  [read-write]

Gets or sets the menu to show.

If no menu has been configured with this instance this will create the menu using the createMenu callback.

Implementation
    public function get menu():ContextMenu
    public function set menu(value:ContextMenu):void
Constructor detail
ContextMenuInputMode()constructor
public function ContextMenuInputMode(menu:ContextMenu = null)

Creates a new instance using the provided menu.

Parameters
menu:ContextMenu (default = null)
Method detail
createContextMenuHandlerInputModeContext()method
protected function createContextMenuHandlerInputModeContext():IInputModeContext

Creates an IInputModeContext for use with the next menuSelect event.

Returns
IInputModeContext — An instance of IInputModeContext.

See also

createMenu()method 
protected function createMenu():ContextMenu

Factory method that creates the initial menu.

Subclasses may override this with more sophisticated implementations.

Returns
ContextMenu — a default ContextMenu
install()method 
public override function install(context:IInputModeContext):void

Installs this mode in the canvas, registering the menu as the canvas' contextMenu.

Note: this also registers the menu for Application.application.root since otherwise the custom menu won't work when a custom cursor is activated.

Parameters
context:IInputModeContext — The canvas to install this mode into.
uninstall()method 
public override function uninstall(context:IInputModeContext):voidParameters
context:IInputModeContext
Event detail
menuSelectevent 
Event object type: com.yworks.canvas.input.CanvasContextMenuEvent

Dispatched when the contextMenu is about to be shown