On this page
Guides
Custom Menu
The CPDFView
supports a right-click menu feature. Right-clicking within the CPDFView
area will trigger a custom menu.
You can set different custom menus for users in various contexts. For instance, setting the page zoom level when right-clicking in a blank area, enabling copy options when right-clicking on text, images, or annotations, etc.
The steps for setting up a custom menu are as follows:
- Register for the custom menu event.
- Create a context menu on
CPDFViewerTool
and add menu items (Copy, Cut, Paste, Delete).
This example shows how to create a custom menu:
C#
// Register custom menu event
toolManager.MouseRightButtonDownHandler += ToolManager_MouseRightButtonDownHandler;
private void ToolManager_MouseRightButtonDownHandler(object sender, MouseEventObject e)
{
// Create a context menu on CPDFViewerTool and add menu items (Copy, Cut, Paste, Delete).
ContextMenu contextMenu = new ContextMenu();
contextMenu.Items.Add(new MenuItem() { Header = "Copy", Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender });
contextMenu.Items.Add(new MenuItem() { Header = "Cut", Command = ApplicationCommands.Cut, CommandTarget = (UIElement)sender });
contextMenu.Items.Add(new MenuItem() { Header = "Paste", Command = ApplicationCommands.Paste, CommandTarget = (UIElement)sender });
contextMenu.Items.Add(new MenuItem() { Header = "Delete", Command = ApplicationCommands.Delete, CommandTarget = (UIElement)sender });
CPDFViewerTool tool = sender as CPDFViewerTool;
tool.ContextMenu = contextMenu;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15