Skip to content

CreateButton

Claude edited this page Oct 26, 2026 · 6 revisions

CreateButton

Command Index · BlitzPlus · Gadgets

CreateButton text$, x%, y%, width%, height%, group%, style%=1  ; returns Int

Works in: BlitzPlus

Makes a button with a caption. The style picks what it is:

Style Kind
1 Push button, sends $401 when clicked. This is the default
2 Check box, toggles between ticked and not and sends the new state
3 Radio button, ticking one unticks the others in the same group
4 Default button, also fires when Enter is pressed inside its group
5 Cancel button, also fires when Escape is pressed inside its group

Add 65536 to keep the button from following when its group is resized. Radio buttons that share a group belong together, so put sets of them on different panels to keep them apart. Use ButtonState and SetButtonState for check boxes and radio buttons.

Graphics 320, 240, 32, 2
win = CreateWindow("Buttons", 10, 10, 300, 200, Desktop(), 3)
push = CreateButton("Push", 10, 10, 120, 28, win)
tick = CreateButton("Check box", 10, 50, 140, 24, win, 2)
a    = CreateButton("Radio A", 10, 90, 140, 24, win, 3)
b    = CreateButton("Radio B", 10, 116, 140, 24, win, 3)
SetButtonState a, True
count = 0
Repeat
	e = WaitEvent()
	If e = $401 And EventSource() = push Then count = count + 1 : SetGadgetText push, "Pushed " + count
Until e = $803

CreateButton

Parameter Type Default Description
text String required Caption of the button.
x Int required Horizontal position inside the group.
y Int required Vertical position inside the group.
width Int required Width of the button.
height Int required Height of the button.
group Int required Window, panel, tabber or canvas that holds it.
style Int 1 Kind of button, see the table. Defaults to 1.

Returns: A handle for the button.

Differences and known gaps:

  • Buttons are drawn in the look of the program, not with the controls of the operating system.

Related commands

Command Index · BlitzPlus · Gadgets

Home · Command Index


Getting started

Language

Tools


Language Features
BlitzBasic
Blitz3D
BlitzPlus
Differences

Clone this wiki locally