feat(ui): ui_scale and ui_box, on-submit, zoom (and a length over a length in calc), on-hold
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
3d2a103dfb
commit
ec9a650e65
24 changed files with 323 additions and 23 deletions
45
examples/library/ui_submit.ludic
Normal file
45
examples/library/ui_submit.ludic
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
# ui_submit.ludic — on-submit on a text field: Enter (or the pad's A) while it has the focus sends what
|
||||
# it holds with event.value; the focus stays, and so does the text, unless clear-on-submit empties it.
|
||||
import "ludic.ui"
|
||||
program UiSubmit {
|
||||
numbers float
|
||||
var said: string = ""
|
||||
var chat: string = ""
|
||||
var name: string = ""
|
||||
view Chat {
|
||||
chat = chat
|
||||
name = name
|
||||
on set_chat(v: string) { chat = v }
|
||||
on set_name(v: string) { name = v }
|
||||
on send(v: string) { said = said + "[" + v + "]" }
|
||||
}
|
||||
const PAGE: string = "<ui><screen name='c'><input type='text' label='Say' value='{chat}' clear-on-submit on-change='set_chat(event.value)' on-submit='send(event.value)'/><input type='text' label='Name' value='{name}' on-change='set_name(event.value)' on-submit='send(event.value)'/></screen></ui>"
|
||||
function frame(i: UiInput) -> void {
|
||||
ui_input(i)
|
||||
ui_show("c", view_chat(), 0.0, 0.0, 400.0, 400.0)
|
||||
}
|
||||
function press(tab: bool, enter: bool, pad: bool, typed: string) -> void {
|
||||
let i = new UiInput
|
||||
i.tab = tab
|
||||
i.enter = enter
|
||||
i.pad_a = pad
|
||||
i.typed = typed
|
||||
frame(i)
|
||||
frame(new UiInput)
|
||||
}
|
||||
entry {
|
||||
ui_backend(new UiBackend)
|
||||
ui_load_text(PAGE, "c.xml")
|
||||
frame(new UiInput)
|
||||
press(true, false, false, "")
|
||||
press(false, false, false, "hi")
|
||||
press(false, true, false, "")
|
||||
let after = `{said} chat '{chat}'`
|
||||
press(false, false, false, "yo")
|
||||
press(false, false, true, "")
|
||||
press(true, false, false, "")
|
||||
press(false, false, false, "Ada")
|
||||
press(false, true, false, "")
|
||||
print(`{after} | {said} chat '{chat}' name '{name}'`)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue