GUI component interaction: Difference between revisions
Content added Content deleted
(Added BaCon version.) |
|||
Line 331: | Line 331: | ||
; Otherwise the script is persistent because it contains |
; Otherwise the script is persistent because it contains |
||
; a timer.</lang> |
; a timer.</lang> |
||
=={{header|BaCon}}== |
|||
Requires BaCon version 4.0.1 or higher, using GTK3. |
|||
<lang bacon>OPTION GUI TRUE |
|||
PRAGMA GUI gtk3 |
|||
DECLARE (*show)() = gtk_widget_show_all TYPE void |
|||
DECLARE (*hide)() = gtk_widget_hide TYPE void |
|||
gui = GUIDEFINE(" \ |
|||
{ type=WINDOW name=window callback=delete-event title=\"Rosetta Code\" width-request=200 } \ |
|||
{ type=BOX name=box parent=window orientation=GTK_ORIENTATION_VERTICAL } \ |
|||
{ type=SPIN_BUTTON name=spin parent=box numeric=TRUE } \ |
|||
{ type=BUTTON_BOX name=bbox parent=box } \ |
|||
{ type=BUTTON name=increment parent=bbox callback=clicked label=\"Increment\" } \ |
|||
{ type=BUTTON name=random parent=bbox callback=clicked label=\"Random\" } \ |
|||
{ type=MESSAGE_DIALOG name=confirm callback=delete-event callback=response,yesno message-type=GTK_MESSAGE_WARNING buttons=GTK_BUTTONS_YES_NO title=\"Warning\" text=\"Get random number?\" }") |
|||
CALL GUISET(gui, "spin", "adjustment", gtk_adjustment_new(1, 0, MAXNUM(float), 1, 1, 0)) |
|||
DECLARE answer TYPE int* |
|||
DECLARE input TYPE FLOATING |
|||
WHILE TRUE |
|||
event$ = GUIEVENT$(gui, TRUE) |
|||
SELECT TOKEN$(event$, 1) |
|||
CASE "window" |
|||
BREAK |
|||
CASE "increment" |
|||
CALL GUIGET(gui, "spin", "value", &input) |
|||
CALL GUISET(gui, "spin", "value", input+1) |
|||
CASE "random" |
|||
CALL GUIFN(gui, "confirm", show) |
|||
CASE "yesno" |
|||
answer = (intptr_t)DEC(TOKEN$(event$, 2)) |
|||
IF *answer = GTK_RESPONSE_YES THEN CALL GUISET(gui, "spin", "value", RANDOM(MAXNUM(float))) |
|||
CALL GUIFN(gui, "confirm", hide) |
|||
ENDSELECT |
|||
WEND</lang> |
|||
=={{header|BBC BASIC}}== |
=={{header|BBC BASIC}}== |