Contents Previous Next Subchapters

Using Push Buttons In A Dialog Window
Syntax addcontrol(captiongeometry, "pushbutton", namecall back)
See Also delwin

Description
Adds a push button control, with the specified geometry , to the Dialog window specified by caption . The character row vector name specifies the text to be placed on the button. The command specified by call back is executed when the button is pressed. (The return value is the control handle for the push button but it is not currently used.)

Example
The following program creates a dialog window with two push buttons labeled "Ok" and "Cancel". When one of the buttons is pressed, the name of the corresponding button is echoed in the command window and the dialog is deleted.

clear
#
Caption  = "Test Dialog"
geometry = [100, 100, 200, 100]
callback = "delwin(Caption);"
adddialog(Caption, geometry, callback);
#
geometry = [20, 20, 50, 20]
name     = "Ok"
callback = [ "print", dquote(name), "; delwin(Caption);"]
addcontrol(Caption, geometry, "pushbutton", name, callback);
#
geometry = [130, 20, 50, 20]
name     = "Cancel"
callback = [ "print", dquote(name), "; delwin(Caption);"]
addcontrol(Caption, geometry, "pushbutton", name, callback);