Context Menu
The contextmenu namespace provides the facility to interact with the context menu api to control whether context menus are enabled, listen to events, add items to appear based on the context, and set the theme of the context menu.
Context Menu
Webworks applications can choose to use an in app contextmenu as opposed to the default operating system menu. The contextmenu provides several facilities to developers to allow them to control the elements that appear in the menu, as well as listen to specific events related to the context menu being triggered and displayed.
Enabling
The contextmenu can be enabled by calling the blackberry.ui.contextmenu.enabled property. When set to true, the contextmenu will capture the context menu events, and pass any events that the user has registered for. When set to false the contextmenu will default to the system, and the developer will have no access to the events described below.
Supported Platform(s)
- BlackBerry 10 |
- Ripple Emulator |
API | BB5.0 | BB6.0 | BB7.0 | PB1.0 | PB2.0 | BB10 | Ripple |
---|---|---|---|---|---|---|---|
blackberry.ui.contextmenu.addItem | Y | Y | |||||
blackberry.ui.contextmenu.defineCustomContext | Y | Y | |||||
blackberry.ui.contextmenu.removeItem | Y | Y | |||||
enabled | |||||||
CONTEXT_ALL | Y | Y | |||||
CONTEXT_LINK | Y | Y | |||||
CONTEXT_IMAGE | Y | Y | |||||
CONTEXT_IMAGE_LINK | Y | Y | |||||
CONTEXT_INPUT | Y | Y | |||||
CONTEXT_TEXT | Y | Y | |||||
ACTION_CANCEL | Y | Y | |||||
ACTION_CLEAR_FIELD | Y | Y | |||||
ACTION_COPY | Y | Y | |||||
ACTION_COPY_IMAGE_LINK | Y | Y | |||||
ACTION_COPY_LINK | Y | Y | |||||
ACTION_CUT | Y | Y | |||||
INSPECT_ELEMENT | Y | Y | |||||
ACTION_OPEN_LINK | Y | Y | |||||
ACTION_PASTE | Y | Y | |||||
ACTIONE_SAVE_IMAGE | Y | Y | |||||
ACTION_SAVE_LINK_AS | Y | Y | |||||
ACTION_SELECT | Y | Y | |||||
ACTION_VIEW_IMAGE | Y | Y |
Configuration Document Settings
To use all of the API described for this object, you must ensure the following settings are in your configuration document: |
You must declare the feature element(s) below in your configuration document: |
Feature ID | BB5.0 | BB6.0 | BB7.0 | PB1.0 | PB2.0 | BB10 | Ripple |
---|---|---|---|---|---|---|---|
<feature id="blackberry.ui.contextmenu" /> | Y | Y |
Permission Elements (PlayBook and BlackBerry 10+) |
---|
This API does not require a <permission> element to be declared in the configuration document of your BlackBerry WebWorks Application. |
Functions
Properties
boolean | enabled |
Constants
String | CONTEXT_ALL |
String | CONTEXT_LINK |
String | CONTEXT_IMAGE |
String | CONTEXT_IMAGE_LINK |
String | CONTEXT_INPUT |
String | CONTEXT_TEXT |
String | ACTION_CANCEL |
String | ACTION_CLEAR_FIELD |
String | ACTION_COPY |
String | ACTION_COPY_IMAGE_LINK |
String | ACTION_COPY_LINK |
String | ACTION_CUT |
String | INSPECT_ELEMENT |
String | ACTION_OPEN_LINK |
String | ACTION_PASTE |
String | ACTIONE_SAVE_IMAGE |
String | ACTION_SAVE_LINK_AS |
String | ACTION_SELECT |
String | ACTION_VIEW_IMAGE |
Functions
static
void
blackberry.ui.contextmenu.addItem
(contexts : String[], action : Object, callback: function())
Allows the developer to add custom items to the context menu. The items will be appended to the end of the list of operating system defined functions. Developers must provide the following parameters to successfully add items to the context menu.
Supported Platforms | |
---|---|
- BlackBerry 10 | |
- Ripple Emulator |
Parameters | |
---|---|
contexts | An array of constants defining which contexts this new item should appear. |
action |
An object which defines the menu item to be added.
actionId: A property that uniquely defines the action to be added to the context menu. label: A string that will be displayed to the user describing the custom context to be performed. ie: Edit icon: A path to the an image to display in the context menu |
callback | A function which runs when the menu item action is executed |
Code Example:
|
static
void
blackberry.ui.contextmenu.defineCustomContext
(context : String, options : Object)
Allows the developer to define a custom context.
Supported Platforms | |
---|---|
- BlackBerry 10 | |
- Ripple Emulator |
Parameters | |
---|---|
context | A String representing the custom context. |
options | An Object that contains the various options to set for the custom context. |
Code Example:
|
static
void
blackberry.ui.contextmenu.removeItem
(contexts : String[], actionId : String)
Allows the developer to remove previously added custom items from the context menu.
Supported Platforms | |
---|---|
- BlackBerry 10 | |
- Ripple Emulator |
Parameters | |
---|---|
contexts | An array of constants defining which contexts this new item should appear. |
actionId | An id that uniquely defines the action to be removed from the context menu. |
Code Example:
|
Properties
static
boolean
enabled
Context Menu enabled allows the developer to enabled and disable crosscut context menus for their application.
Supported Platforms |
---|
Parameters | |
---|---|
enabled | property that sets the contextmenu to enabled or disabled |
Code Example:
|
Constants
static
String
CONTEXT_ALL
Constant denoting all contexts.
Supported Platforms | |
---|---|
- BlackBerry 10 | |
- Ripple Emulator |
static
String
CONTEXT_LINK
Constant denoting the context of links.
Supported Platforms | |
---|---|
- BlackBerry 10 | |
- Ripple Emulator |
static
String
CONTEXT_IMAGE
Constant denoting the context of images.
Supported Platforms | |
---|---|
- BlackBerry 10 | |
- Ripple Emulator |
static
String
CONTEXT_IMAGE_LINK
Constant denoting the context of image links.
Supported Platforms | |
---|---|
- BlackBerry 10 | |
- Ripple Emulator |
static
String
CONTEXT_INPUT
Constant denoting the context of input fields.
Supported Platforms | |
---|---|
- BlackBerry 10 | |
- Ripple Emulator |
static
String
CONTEXT_TEXT
Constant denoting the context of text.
Supported Platforms | |
---|---|
- BlackBerry 10 | |
- Ripple Emulator |
static
String
ACTION_CANCEL
Constant denoting the actionId of cancel
Supported Platforms | |
---|---|
- BlackBerry 10 | |
- Ripple Emulator |
static
String
ACTION_CLEAR_FIELD
Constant denoting the actionId of clear field.
Supported Platforms | |
---|---|
- BlackBerry 10 | |
- Ripple Emulator |
static
String
ACTION_COPY
Constant denoting the actionId of copy.
Supported Platforms | |
---|---|
- BlackBerry 10 | |
- Ripple Emulator |
static
String
ACTION_COPY_IMAGE_LINK
Constant denoting the actionId of copy image link.
Supported Platforms | |
---|---|
- BlackBerry 10 | |
- Ripple Emulator |
static
String
ACTION_COPY_LINK
Constant denoting the actionId of copy link.
Supported Platforms | |
---|---|
- BlackBerry 10 | |
- Ripple Emulator |
static
String
ACTION_CUT
Constant denoting the actionId of cut.
Supported Platforms | |
---|---|
- BlackBerry 10 | |
- Ripple Emulator |
static
String
INSPECT_ELEMENT
Constant denoting the actionId of inspect element
Supported Platforms | |
---|---|
- BlackBerry 10 | |
- Ripple Emulator |
static
String
ACTION_OPEN_LINK
Constant denoting the actionId of open link.
Supported Platforms | |
---|---|
- BlackBerry 10 | |
- Ripple Emulator |
static
String
ACTION_PASTE
Constant denoting the actionId of paste.
Supported Platforms | |
---|---|
- BlackBerry 10 | |
- Ripple Emulator |
static
String
ACTIONE_SAVE_IMAGE
Constant denoting the actionId of save image.
Supported Platforms | |
---|---|
- BlackBerry 10 | |
- Ripple Emulator |
static
String
ACTION_SAVE_LINK_AS
Constant denoting the actionId of save link as.
Supported Platforms | |
---|---|
- BlackBerry 10 | |
- Ripple Emulator |