{"id":28592,"date":"2013-06-27T14:29:46","date_gmt":"2013-06-27T08:59:46","guid":{"rendered":"http:\/\/vskills.in\/certification\/tutorial\/?p=28592"},"modified":"2024-04-12T14:16:11","modified_gmt":"2024-04-12T08:46:11","slug":"context-menus","status":"publish","type":"page","link":"https:\/\/www.vskills.in\/certification\/tutorial\/context-menus\/","title":{"rendered":"Context Menus"},"content":{"rendered":"<p><a class=\"vsc\" href=\"http:\/\/www.vskills.in\/certification\/Certified Blackberry Apps Developer\"><span class=\"vsc-cn\" style=\"text-align: center;\"><span style=\"color: red;\">Certify and Increase Opportunity.<\/span><br \/>\n<span style=\"color: green;\">Be <\/span><br \/>\nGovt. Certified Blackberry Apps Developer<br \/>\n<\/span><\/a><\/p>\n<p>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.<\/p>\n<h4>Enabling<\/h4>\n<p>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.<\/p>\n<h4>Context Information<\/h4>\n<p>Context information is available from the window object through a contextmenu event &#8220;window.oncontextmenu&#8221;. This event is triggered whenever there is a context menu request from the client. This event provides all the contextual information needed to store the context yourself and save what element the context menu was triggered on. This allows you to perform a multitude of different actions once a context menu has been requested.<\/p>\n<div>\n<p><b>Code Example:<\/b><\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre>&lt;script type=\"text\/javascript\"&gt;\r\nfunction addMenuItemToCustomContext() {\r\n    var myItem = {actionId: '7', label: 'itemForCustom', icon:'local:\/\/\/img\/myIcon.png'},\r\n        contexts = [\"myContext\"];\r\n    blackberry.ui.contextmenu.addItem(contexts, myItem);\r\n}\r\n\r\nfunction addAdditionalItemsFromCustomContext) {\r\n    var options = {\r\n        includeContextItems: [blackberry.ui.contextmenu.CONTEXT_IMAGE, blackberry.ui.contextmenu.CONTEXT_IMAGE_LINK],\r\n        includePlatformItems: true,\r\n        includeMenuService: true\r\n    };\r\n    blackberry.ui.contextmenu.defineCustomContext(\"myContext\", options);\r\n}\r\n\r\nfunction removeAdditionalItemsFromCustomContext) {\r\n    var options = {\r\n        includeContextItems: [],\r\n        includePlatformItems: false,\r\n        includeMenuService: false\r\n    };\r\n    blackberry.ui.contextmenu.defineCustomContext(\"myContext\", options);\r\n}\r\n&lt;\/script&gt;\r\n&lt;div data-webworks-context=\"myContext\"&gt;I am a custom context!&lt;\/div&gt;<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div>\n<div>\n<h2>Learning Resources:<\/h2>\n<\/div>\n<div>\n<table>\n<tbody>\n<tr>\n<td>Sample &#8211; Using Custom Context\u00a0Sample that demonstrates how to use the BlackBerry Custom Context API [BlackBerry on GitHub].<\/p>\n<pre>&lt;script type=\"text\/javascript\"&gt;\r\n\r\n\/\/ Update the path from a small icon to a full image\r\nfunction translateIcontoFullImage (path) {\r\n    if (path &amp;&amp; path.indexOf('.ico') !== -1) {\r\n        return path.replace('.ico', '.jpeg');\r\n    }\r\n}\r\n\r\nfunction onContextMenu (contextEvent) {\r\n    var srcElement = contextEvent.srcElement;\r\n    blackberry.invoke.interrupter = function (request) {\r\n        \/\/ Check if this is an image we wish to translate\r\n        if (srcElement &amp;&amp; srcElement.src {\r\n            request.uri = translateIcontoFullImage(srcElement.src);\r\n        }\r\n\r\n        \/\/ Return the updated request object\r\n        return request;\r\n    };\r\n\r\n}\r\n\r\nwindow.addEventListener('oncontextmenu', onContextMenu);\r\n\r\n&lt;\/script&gt;<\/pre>\n<h3>Custom Context Menu<\/h3>\n<p>Webworks applications can give Dom elements custom context by using the data-webworks-context xml attribute. When a Dom element contains this attribute, custom context menus will be activated when the element is long pressed. Once you have created a custom context using the data-webworks-context attribute, you can then use addItem to add items to the custom context. You can also optionally use defineCustomContext to further define the items shown.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<div>\n<div>\n<h2>Supported Platform(s)<\/h2>\n<\/div>\n<div>\n<table>\n<tbody>\n<tr>\n<td>&#8211; BlackBerry 10<\/td>\n<\/tr>\n<tr>\n<td>&#8211; Ripple Emulator<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>View Supported Platform Table<\/p>\n<\/div>\n<\/div>\n<div>\n<div>\n<h2>Configuration Document Settings<\/h2>\n<\/div>\n<div>\n<table>\n<tbody>\n<tr>\n<td>To use\u00a0<span style=\"text-decoration: underline;\">all<\/span>\u00a0of the API described for this object, you must ensure the following settings are in your configuration document:<\/td>\n<\/tr>\n<tr>\n<td>You must declare the feature element(s) below in your configuration document:<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<table>\n<thead>\n<tr>\n<th>Feature ID<\/th>\n<th>BB5.0<\/th>\n<th>BB6.0<\/th>\n<th>BB7.0<\/th>\n<th>PB1.0<\/th>\n<th>PB2.0<\/th>\n<th>BB10<\/th>\n<th>Ripple<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>&lt;feature id=&#8221;blackberry.ui.contextmenu&#8221; \/&gt;<\/td>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<td>Y<\/td>\n<td>Y<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div>\n<table>\n<tbody>\n<tr>\n<th>Permission Elements (PlayBook and BlackBerry 10+)<\/th>\n<\/tr>\n<tr>\n<td>This API does not require a &lt;permission&gt; element to be declared in the configuration document of your BlackBerry WebWorks Application.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<div>\n<div>\n<div>\n<h2>Functions<\/h2>\n<\/div>\n<div>\n<table>\n<tbody>\n<tr>\n<td>void<\/td>\n<td>blackberry.ui.contextmenu.addItem<\/td>\n<\/tr>\n<tr>\n<td>void<\/td>\n<td>blackberry.ui.contextmenu.defineCustomContext<\/td>\n<\/tr>\n<tr>\n<td>void<\/td>\n<td>blackberry.ui.contextmenu.removeItem<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<div>\n<div>\n<h2>Properties<\/h2>\n<\/div>\n<div>\n<table>\n<tbody>\n<tr>\n<td>boolean<\/td>\n<td>enabled<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<div>\n<div>\n<h2>Constants<\/h2>\n<\/div>\n<div>\n<table>\n<tbody>\n<tr>\n<td>String<\/td>\n<td>CONTEXT_ALL<\/td>\n<\/tr>\n<tr>\n<td>String<\/td>\n<td>CONTEXT_LINK<\/td>\n<\/tr>\n<tr>\n<td>String<\/td>\n<td>CONTEXT_IMAGE<\/td>\n<\/tr>\n<tr>\n<td>String<\/td>\n<td>CONTEXT_IMAGE_LINK<\/td>\n<\/tr>\n<tr>\n<td>String<\/td>\n<td>CONTEXT_INPUT<\/td>\n<\/tr>\n<tr>\n<td>String<\/td>\n<td>CONTEXT_TEXT<\/td>\n<\/tr>\n<tr>\n<td>String<\/td>\n<td>ACTION_CANCEL<\/td>\n<\/tr>\n<tr>\n<td>String<\/td>\n<td>ACTION_CLEAR_FIELD<\/td>\n<\/tr>\n<tr>\n<td>String<\/td>\n<td>ACTION_COPY<\/td>\n<\/tr>\n<tr>\n<td>String<\/td>\n<td>ACTION_COPY_IMAGE_LINK<\/td>\n<\/tr>\n<tr>\n<td>String<\/td>\n<td>ACTION_COPY_LINK<\/td>\n<\/tr>\n<tr>\n<td>String<\/td>\n<td>ACTION_CUT<\/td>\n<\/tr>\n<tr>\n<td>String<\/td>\n<td>INSPECT_ELEMENT<\/td>\n<\/tr>\n<tr>\n<td>String<\/td>\n<td>ACTION_PASTE<\/td>\n<\/tr>\n<tr>\n<td>String<\/td>\n<td>ACTIONE_SAVE_IMAGE<\/td>\n<\/tr>\n<tr>\n<td>String<\/td>\n<td>ACTION_SAVE_LINK_AS<\/td>\n<\/tr>\n<tr>\n<td>String<\/td>\n<td>ACTION_SELECT<\/td>\n<\/tr>\n<tr>\n<td>String<\/td>\n<td>ACTION_VIEW_IMAGE<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<div>\n<h2><\/h2>\n<div class=\"apply\">\n<h3>Apply for Blackberry Apps Certification Now!!<\/h3>\n<p><a href=\"http:\/\/www.vskills.in\/certification\/Certified-Blackberry-Apps-Developer\">http:\/\/www.vskills.in\/certification\/Certified-Blackberry-Apps-Developer<\/a><\/p>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Certify and Increase Opportunity. Be Govt. Certified Blackberry Apps Developer 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&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[3346],"tags":[4365],"class_list":["post-28592","page","type-page","status-publish","hentry","category-blackberry-apps","tag-context-menus"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Context Menus - Tutorial<\/title>\n<meta name=\"description\" content=\"Context Menus. Government of India Certification in Blackberry Apps Development. Get certified and improve employability.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.vskills.in\/certification\/tutorial\/context-menus\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Context Menus - Tutorial\" \/>\n<meta property=\"og:description\" content=\"Context Menus. Government of India Certification in Blackberry Apps Development. Get certified and improve employability.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.vskills.in\/certification\/tutorial\/context-menus\/\" \/>\n<meta property=\"og:site_name\" content=\"Tutorial\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/vskills.in\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-12T08:46:11+00:00\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/context-menus\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/context-menus\/\",\"name\":\"Context Menus - Tutorial\",\"isPartOf\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\"},\"datePublished\":\"2013-06-27T08:59:46+00:00\",\"dateModified\":\"2024-04-12T08:46:11+00:00\",\"description\":\"Context Menus. Government of India Certification in Blackberry Apps Development. Get certified and improve employability.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/context-menus\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.vskills.in\/certification\/tutorial\/context-menus\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/context-menus\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Context Menus\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"name\":\"Tutorial\",\"description\":\"Vskills - A initiative in elearning and certification\",\"publisher\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\",\"name\":\"Vskills\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"contentUrl\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"width\":73,\"height\":55,\"caption\":\"Vskills\"},\"image\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/vskills.in\/\",\"https:\/\/x.com\/vskills_in\",\"https:\/\/www.linkedin.com\/company-beta\/1371554\/\",\"https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Context Menus - Tutorial","description":"Context Menus. Government of India Certification in Blackberry Apps Development. Get certified and improve employability.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.vskills.in\/certification\/tutorial\/context-menus\/","og_locale":"en_US","og_type":"article","og_title":"Context Menus - Tutorial","og_description":"Context Menus. Government of India Certification in Blackberry Apps Development. Get certified and improve employability.","og_url":"https:\/\/www.vskills.in\/certification\/tutorial\/context-menus\/","og_site_name":"Tutorial","article_publisher":"https:\/\/www.facebook.com\/vskills.in\/","article_modified_time":"2024-04-12T08:46:11+00:00","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/context-menus\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/context-menus\/","name":"Context Menus - Tutorial","isPartOf":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website"},"datePublished":"2013-06-27T08:59:46+00:00","dateModified":"2024-04-12T08:46:11+00:00","description":"Context Menus. Government of India Certification in Blackberry Apps Development. Get certified and improve employability.","breadcrumb":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/context-menus\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.vskills.in\/certification\/tutorial\/context-menus\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/context-menus\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.vskills.in\/certification\/tutorial\/"},{"@type":"ListItem","position":2,"name":"Context Menus"}]},{"@type":"WebSite","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","name":"Tutorial","description":"Vskills - A initiative in elearning and certification","publisher":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization","name":"Vskills","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","contentUrl":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","width":73,"height":55,"caption":"Vskills"},"image":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/vskills.in\/","https:\/\/x.com\/vskills_in","https:\/\/www.linkedin.com\/company-beta\/1371554\/","https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw"]}]}},"_links":{"self":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/28592","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/comments?post=28592"}],"version-history":[{"count":5,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/28592\/revisions"}],"predecessor-version":[{"id":64858,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/28592\/revisions\/64858"}],"wp:attachment":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/media?parent=28592"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/categories?post=28592"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/tags?post=28592"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}