Specifies a command or callback routine to be run when the pop-up menu is raised in the Editor window.
Note: this parameter is valid only in an Editor window.
Scope: Document
Syntax
set popupinit [drop] Command
query popupinit
Options
Command |
A command or callback routine to run when the pop-up menu is requested, along with any parameters required. |
drop |
Remove the specified callback routine from the callback list. |
Description
You can use the popupinit parameter to specify a command or callback routine to be run between the time you request the pop-up menu and the time it appears. The callback routine can use any of the Editor commands, including the set and query commands, to work with items of interest. A typical callback routine might modify the contents of the pop- up menu, depending on the state of the document being edited when the pop-up menu is requested.
The pop-up menu can have multiple callback routines, which are called in LIFO order. If one of the callback routines returns a non-zero value, no further callbacks will be called.
A callback routine can be removed from the callback list by using the drop argument with the popupinit parameter. If a callback routine is not explicitly dropped, it remains active until the document is closed.
Examples
set popupinit msg Pop-up menu raised!
set popupinit drop msg Pop-up menu raised!
query popupinit
The primary callback routine used to create the menu choice is shown below:
/* Macro file "del_empt.lx" */
/* Enable a pop-up menu item if empty lines are found at the top of a file */
'mark set predel' /* Save the cursor position for later use */
'top' /* Move cursor to first line in the file */
'extract content' /* Get contents of first line */
/* A pair of Editor commands will be run if the pop-up menu item is */
/* selected - 1. run the macro called delempty.lx */
/* - 2. remove the menu item from the pop-up menu when done */
/* These commands are assigned to a variable for easier reading in */
/* the next section where the pop-up menu item is actually created. */
run_cmd = "mult ;macro delempty ;set popupmenu.Delete_leading_empty_lines"
/* Check line and add pop-up if first line is empty */
if (content = "") then do /* line is empty */
/* Create a pop-up menu item that runs commands to first delete empty */
/* leading lines, and then removes itself from the pop-up menu. */
'set popupmenu.Delete_leading_empty_lines 'run_cmd
end
'mark find predel' /* Restore original cursor position if still existing */
'mark clear predel' /* Clear the mark saving the original cursor position */
exit 0
This callback routine calls another macro file called delempty.lx that actutally removes the leading empty lines from the file.
/* Macro file "delempty.lx" */
/* Find and remove leading empty lines */
'mark set predel' /* Save the cursor position for later use */
'top' /* move cursor to first line in file */
'extract content' /* get contents of first line */
do while (content="") /* loop while empty lines found */
'block mark element' /* highlight empty lines */
'next element' /* move cursor to next line */
'extract content' /* get contents of next line */
end
'block delete' /* delete marked block */
'mark find predel' /* Restore cursor position if still existing */
'mark clear predel' /* Clear mark saving the cursor position */
exit 0
set popupinit del_empt.lx
set popupinit drop del_empt.lx
API Return Code
None.
![]()
popuplink Parameter
popupmenu Parameter
popupmenuid Parameter
popupmenulist Parameter
