ImageGear for .NET
Adding a Context Menu Item to the Top Level of Context Menu

The following example demonstrates how to add context menu items to the top level of the context menu.

For Ajax server users, please comment out the first portion of the code below and uncomment the second.

Example
Copy Code
// get PageView control with "pluginPageView" identifier from the HTML page in jQuery plugin
var pageView = $("#pluginPageView").ImGearPageViewPlugin();
// get PageView control with "pluginPageView" identifier from the HTML page for Ajax server
//var pageView = $.find("pluginPageView");
// get context menu for image and HandPan mouse tool
var contextMenu = pageView.getContextMenu(null, ImageGear.Web.UI.MouseTool.HandPan);
// add separator to the end of list
contextMenu.insert(contextMenu.get_size(), new ImageGear.Web.UI.ContextMenuItem(ImageGear.Web.UI.ContextMenuItemType.Separator));
// create new context menu item
var alertMenu = new ImageGear.Web.UI.ContextMenuItem
    (ImageGear.Web.UI.ContextMenuItemType.UserMenuItem,
    'Throw Alert', undefined,
    function (pageView, mark) { alert('My alert works!'); }
);
// add alert context menu item after the separator
contextMenu.insert(contextMenu.get_size(), alertMenu);
// set the renew context menu for HandPan mouse tool
pageView.setContextMenuForTool(contextMenu, null, ImageGear.Web.UI.MouseTool.HandPan);

 

 


©2014. Accusoft Corporation. All Rights Reserved.

Send Feedback