text$ - Initial text for the button
x,y,width,height - Initial shape for the button group - A group gadget handle style - Optional style flags |
CreateButton creates a button gadget, and returns its handle.
Style can be one of: 1 - A standard push button 2 - A Checkbox style button 3 - A Radio style button 4 - A push button that is automatically clicked by a 'return' keystroke 5 - A push button that is automatically clicked by an 'escape' keystroke The default style is a standard push button. Note the automatic click feature only works when a button or textfield within the same gadget group is currently active. See also: SetButtonState, ButtonState. |
; Example based on one provided by Mag, extended by Mark Tiffany
; first, let's create a window WinHandle=CreateWindow("Dessert Menu",0,0,400,250) ; now create some buttons OptionButton1=CreateButton("Apple Pie",50,10,300,40,WinHandle,3) OptionButton2=CreateButton("Cheesecake",50,40,300,40,WinHandle,3) Checkbox=CreateButton("With Cream",50,70,300,40,WinHandle,2) ExitButton=CreateButton("Place Order",50,120,300,40,WinHandle) ; now loop and deal with events as they arise Repeat If WaitEvent()=$401 Then If EventSource()=ExitButton Then Exit End If Forever ; and report the selected options! msg$ = "You selected " If ButtonState(OptionButton1) Then msg$=msg$+"Apple Pie " ElseIf ButtonState(OptionButton2) Then msg$=msg$+"Cheesecake " Else msg$=msg$+"Nothing " End If If ButtonState(Checkbox) Then msg$=msg$+"with cream" Notify msg$ End |