Core Function GUICreateContextMenu

From Sputnik Wiki
Jump to: navigation, search
GUICreate( "ContextMenu", <gui object> )

Contents

Description

Create a Context Menu which is used when right clicking the object

Parameters

gui object

The GUI object to place the Menu on.

Return Value

Success: Returns the new GUI object.

Failure: Returns 0 if error occurs.

Example

// Create the GUI
$GUI = GUICreate("Window", "Hello", 200, 200);
// Show the GUI
GUILoad( $GUI );
// Create a button -- This button will simply display a message
$Button = GUICreate("Button", $GUI, "Right click on me!", 8, 8);
$Menu = GUICreate("ContextMenu", $GUI);
$MenuA = GUICreate("MenuItem", $Menu, "Test");
$MenuB = GUICreate("MenuItem", $Menu, "Test2");
$MenuC = GUICreate("MenuItem", $Menu, "Test3");
GUISetProp($Button, "ContextMenu", $Menu);
// Add a link to the context menu
GUILink($MenuA, "Click", 'onClickMenuItemA($me);');
GUILink($MenuB, "Click", 'onClickMenuItemB($me);');
GUILink($MenuC, "Click", 'onClickMenuItemC($me);');
// Keep the GUI running as long as long as the window is open
While ( GUIStatus( $GUI ) ) DoEvents( );
 
Function onClickMenuItemA( $me )
{
	say "You clicked 'Test' menu item";
}
 
Function onClickMenuItemB( $me )
{
	say "You clicked 'Test2' menu item";
}
 
Function onClickMenuItemC( $me )
{
	say "You clicked 'Test3' menu item";
}
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox