This documentation relates to Opera's now deprecated .oex Extension API framework for Opera versions <= 12.15 and also provided by our OEX2NEX shim library.
For the latest Opera Extensions API documentation for Opera versions > 12.15 please consult the latest Opera Extensions API documentation online.
The type
attribute is used to define the type of a menu item. The list of valid type
values includes entry
, folder
and line
. This attribute defaults to a value of entry
.
DOMString type
The following example creates an item with type folder
in the context menu. This is not clickable — instead, sub-menu items will appear when hovered over or otherwise activated. These sub-menu items have the default type which is entry
, and so they are clickable.
<!--
The configuration file ('config.xml').
-->
<?xml version='1.0' encoding='utf-8'?>
<widget xmlns="http://www.w3.org/ns/widgets">
...
<feature name="opera:contextmenus"/>
...
</widget>
//
// The background process (e.g. index.html)
//
if (opera.contexts.menu) {
var menu = opera.contexts.menu;
// Create menu item properties objects
var itemProps = {
title: 'Translate this page',
type: 'folder'
}
var itemPropsEnglish = {
title: 'English',
onclick: function(event) {
doTranslate(event.pageURL, 'English');
}
};
var itemPropsJapanese = {
title: 'Japanese',
onclick: function(event) {
doTranslate(event.pageURL, 'Japanese');
}
};
// Create menu items with the specified properties
var item = menu.createItem(itemProps);
var itemEnglish = menu.createItem(itemPropsEnglish);
var itemJapanese = menu.createItem(itemPropsJapanese);
// Add the menu item to the context menu
menu.addItem(item);
// Add the sub-menu items to the main menu item
item.addItem(itemEnglish);
item.addItem(itemJapanese);
}