GUI enabling/disabling of controls: Difference between revisions

m
→‎{{header|Wren}}: Changed to Wren S/H
m (→‎{{header|Wren}}: Changed to Wren S/H)
 
(5 intermediate revisions by 3 users not shown)
Line 269:
; Ensures the script ends when the GUI is closed.</syntaxhighlight>
 
=={{header|BaConBASIC}}==
==={{header|BaCon}}===
This code requires BaCon 4.0.1 or higher.
<syntaxhighlight lang="bacon">OPTION GUI TRUE
Line 306 ⟶ 307:
WEND</syntaxhighlight>
 
==={{header|BBC BASIC}}===
{{works with|BBC BASIC for Windows}}
<syntaxhighlight lang="bbcbasic"> INSTALL @lib$+"WINLIB2"
Line 877 ⟶ 878:
HandleEvents
</syntaxhighlight>
[[File:GUIEnableDisableControlsFBGUIEnableDisableControls350FB.png]]
 
=={{header|Gambas}}==
Line 2,994 ⟶ 2,995:
End Select
End Sub</syntaxhighlight>
 
=={{header|V (Vlang)}}==
Graphical
 
Notes:
 
1) "v install ui" to get, also to locally check source and examples.
 
2) For alternative UI toolkits, check github.com/vlang/awesome-v (Awesome V).
 
<syntaxhighlight lang="Zig">
import ui
import gx
 
const (
win_width = 400
win_height = 40
)
 
[heap]
struct App {
mut:
window &ui.Window = unsafe {nil}
counter string = "0"
}
 
fn main() {
mut app := &App{}
app.window = ui.window(
width: win_width
height: win_height
title: "Counter"
mode: .resizable
layout: ui.row(
spacing: 5
margin_: 10
widths: ui.stretch
heights: ui.stretch
children: [
ui.textbox(
max_len: 20
read_only: false
is_numeric: true
text: &app.counter
),
ui.button(
text: "increment"
bg_color: gx.light_gray
radius: 5
border_color: gx.gray
on_click: app.btn_click_inc
),
ui.button(
text: "decrement"
bg_color: gx.light_gray
radius: 5
border_color: gx.gray
on_click: app.btn_click_dec
),
]
)
)
ui.run(app.window)
}
 
fn (mut app App) btn_click_inc(mut btn ui.Button) {
if app.counter.int() > 10 {
btn.disabled = true
return
}
app.counter = (app.counter.int() + 1).str()
}
 
fn (mut app App) btn_click_dec(mut btn ui.Button) {
if app.counter.int() < 0 {
btn.disabled = true
return
}
app.counter = (app.counter.int() - 1).str()
}
</syntaxhighlight>
 
=={{header|Wren}}==
{{libheader|DOME}}
{{libheader|Wren-polygon}}
<syntaxhighlight lang="ecmascriptwren">import "graphics" for Canvas, Color
import "input" for Mouse, Keyboard
import "dome" for Window
9,479

edits