Creating a Command Widget
A command widget is used for command entry and provides a built-in command history mechanism. The command widget includes a text input field, a label for the text input field, and a command history window.
The WwCommand function creates a command widget. Use WwGetValue in the callback routine to obtain the strings entered from the command.
The user types a command in the text input field and presses <Return> to execute the command. The command is then added to the end of the command history window. When the user clicks on a command in the command history window, the command is displayed in the text entry field, ready to be executed. The user can double-click on a command in the command history list to execute it directly. This also adds the command to the end of the list.
 
note
Command widgets are popup widgets. This means that they must have an intermediate widget, such as a button, as their parent. The popup widget appears after the user selects this intermediate button. See the following Example section for more information.
Example
The following example shows a simple WwCommand call. To run the example, enter the callback procedures in a file and compile them with the .RUN command. Then enter the widget commands at the WAVE> prompt.
CommandOK is a callback that is executed when the user enters the command and presses <Return>, or double-clicks the command from the history list. CommandDone is a callback that is executed when the user quits the command window. The Title keyword specifies a name for the command window, and Position specifies its location on the screen. The result is shown in Figure 5-27: Command Widget.
Callback Procedures
PRO CbuttonCB, wid, data
command = WwCommand(wid, 'CommandOK', 'CommandDone', Title= $
'Command Entry Window', Position=[300,300])
END
PRO CommandOK, wid, shell
; Obtain the string entered in the text input field.
value = WwGetValue(wid)
PRINT, value
END
PRO CommandDone, wid, shell
status = WwSetValue(shell, /Close)
END
Widget Commands
top=WwInit('ww_ex17', 'Examples', layout)
button=WwButtonBox(layout, 'Command', 'CbuttonCB')
status=WwSetValue(top, /Display)
WwLoop
 
Figure 5-27: Command Widget