This executable supports three types of button SOBs.
Each button is created using the SOB-ADD-BUTTON command
SOB ( _
<Parent: number expression> ,_
"ADD" , _
"BUTTON" , _"button type" ,
"<TITLE: string expression>" , _)
Where buttontype
(enclosed in a pair of "
) must be replaced by one of the following (case insensitive):
- push
- check
- radio
The following script will generate 8 buttons, of which the last 2 radio buttons belong to a different container than the first 2 radio buttons.
Run the script and click on the buttons. See how the two groups of radio buttons are independent.
Above the buttons is a label field which is used to show which button has been pressed. The script also shows how to set/get the colour of a button.
newscript
dim myWindow = sob (0, "add","window","Hello World")
function ClickMyWindow ( sobid )
sob ( myWindow, "delete")
quit
End function
sob ( myWindow , "ON" , "CLICK" , "ClickMyWindow" )
dim myMenuBar = sob (myWindow , "add" , "menu" , "bar" )
dim myMenuFile = sob (myMenuBar , "add" , "menu" , "Horizontal" , "File" )
dim myFileExit = sob ( myMenuFile , "add" , "menu" , "Vertical" , "Exit" )
sob ( myFileExit , "ON" , "CLICK" , "ClickMyWindow")
' --------------------
dim myContainer = sob ( myWindow , "add" , "CONTAINER" , "COLUMN" , 3)
' --------------------
dim myLabel = sob ( myContainer, "add" , "LABEL" , " " )
' --------------------
dim btnPushA = sob ( myContainer, "add" , "BUTTON" , "Push" , "Push button A" )
dim btnPushB = sob ( myContainer, "add" , "BUTTON" , "Push" , "Push button B" )
' --------------------
dim btnCheckC = sob ( myContainer, "add" , "BUTTON" , "Check" , "Check button C" )
dim btnCheckD = sob ( myContainer, "add" , "BUTTON" , "Check" , "Check button D" )
' --------------------
dim btnRadioE = sob ( myContainer, "add" , "BUTTON" , "Radio" , "Radio button E" )
dim btnRadioF = sob ( myContainer, "add" , "BUTTON" , "Radio" , "Radio button F" )
' --------------------
' radio buttons G & H belong to a different container than radio buttons E & F
dim myRow = sob ( myWindow , "add" , "CONTAINER" , "ROW" , 3)
dim btnRadioG = sob ( myRow , "add" , "BUTTON" , "Radio" , "Radio button G" )
dim btnRadioH = sob ( myRow , "add" , "BUTTON" , "Radio" , "Radio button H" )
' --------------------
dim lastPushBtnId = 0
function Press ( sobid )
sob ( myLabel , "SET", "TITLE" , "Press received from -" & sob( sobid , "get" , "TITLE") )
if ( lastPushBtnId = sobid ) then
if ( sob(lastPushBtnId , "GET", "RGB") == rgb(255,255,0) ) then
sob(lastPushBtnId , "SET", "RGB" , rgb( 0,255,255) )
ELSE
sob(lastPushBtnId , "SET", "RGB" , rgb(255,255,0) )
End IF
ELSE
sob(sobid , "SET", "RGB" , rgb(255,255,0) )
sob( lastPushBtnId , "SET", "RGB" , rgb(235,235,235) )
END IF
lastPushBtnId = sobId
End function
sob ( btnPushA , "ON" , "CLICK" , "Press")
sob ( btnPushB , "ON" , "CLICK" , "Press")
' --------------------
function Checked ( sobid )
sob( sobid , "set" , "check" , ! sob( sobid , "get" , "check") )
sob ( myLabel , "SET", "TITLE" , "Check received from -" & sob( sobid , "get" , "TITLE") )
End function
sob ( btnCheckC , "ON" , "CLICK" , "Checked")
sob ( btnCheckD , "ON" , "CLICK" , "Checked")
' --------------------
function Clicked ( sobid )
sob ( myLabel , "SET", "TITLE" , "Check received from -" & sob( sobid , "get" , "TITLE") & "-" )
End function
sob ( btnRadioE , "ON" , "CLICK" , "Clicked")
sob ( btnRadioF , "ON" , "CLICK" , "Clicked")
sob ( btnRadioG , "ON" , "CLICK" , "Clicked")
sob ( btnRadioH , "ON" , "CLICK" , "Clicked")
' --------------------
sob ( myWindow , "SET" , "SHRINK" )
The following is a snapshot of the GUI before selecting any button(s).
Functional specifications for button related SOB commands:
Add – Button
SOB ( _
<Parent: number expression> ,_
"ADD" , _
"BUTTON" , _"button type" ,
"<TITLE: string expression>" , _)
Where buttontype
(enclosed in a pair of "
) must be replaced by one of the following (case insensitive):
- push
- check
- radio