PopupMenu Class

Description

PopupMenu is the class for context-sensitive menus that pop up when you click the right mouse button or some other key combination. Popup menu items change dynamically, depending on the point at which the popup menu appears.

Availability

This class is supported only on the Classic Agent.

Inheritance

PopupMenu derives from the Menu class; no classes derive from this class.

Methods

PopupMenu inherits all its methods from the AnyWin class and Menu class.

Properties

PopupMenu inherits all its properties from the AnyWin class and Menu class.

Notes

To use popup menus, you define a new class, which inherits from the PopupMenu class. The children of this class should be the menu items on the popup menu. You then include the popup menu class as a child of each control to which the popup menu applies. For information on defining your own classes, see the winclass declaration.

Example

The following example is based on Notepad and illustrates how to declare and test popup menus on the Windows platform with the Classic Agent.

	[ ] const wMainWindow = Notepad
	[ ] 
	[ ] window MainWin Notepad
	[-] multitag "*Notepad"
		[ ] "$C:\WINNT\System32\notepad.exe"
	[ ] 
	[ ] const sDir = "C:\WINNT\Profiles\markm.000\Desktop"
	[ ] 
	[ ] const sCmdLine = "C:\WINNT\System32\notepad.exe"
	[ ] 
	[ ] Menu File
	[ ] Menu Edit
	[ ] Menu Search
	[ ] Menu Help
	[-] TextField Text
		[ ] tag "$15"
	[ ] MyPopupMenu RightMenu
	[ ] 
	[ ] //MyPopupMenu is a new class inherited from PopupMenu
	[ ] winclass MyPopupMenu : PopupMenu
	[ ] // Point is the position where you click to invoke
	[ ] // the menu (or it can be reassigned dynamically to test
	[ ] // menu invoked from a variety of points)
	[-] POINT Point
		[ ] tag "$PopupMenu/({Point.x},{Point.y})"
	[ ] // Declare all possible menu items for the popup menu
	[-] MenuItem Cut
		[ ] tag "Cut"
	[-] MenuItem Copy
		[ ] tag "Copy"
	[-] MenuItem Paste
		[ ] tag "Paste"
	[-] MenuItem SelectAll 
		[ ] tag "Select All"
	[ ] 
	[ ] window MessageBoxClass MessageBox

The following is a script that invokes a popup menu and selects a menu item.

	[-] testcase testnotepad()
		[ ] Notepad.SetActive()
		[ ] Notepad.Text.SetPosition (1, 1)
		[ ] Notepad.Text.TypeKeys ("Test of Popup Menu Class<Enter>")
		[ ] //Use the right mouse button, button 2
		[ ] Agent.SetOption (OPT_MENU_INVOKE_POPUP,"<Button2><Up><Down>")
		[ ] // Define specific point for the popup menu to appear
		[ ] Notepad.Text.RightMenu.Point = {100, 250}
		[ ] // Invoke and select the popup menu
		[ ] Notepad.Text.RightMenu.SelectAll.Pick()