- <input type="number" min max step>: typed digits replace its value (a minus when min allows one, a point when step has a fraction), Enter or leaving the field commits them held between min and max, the left and right arrows step it. - <input type="key">: Enter or a click starts it listening and the next key is its value, Tab, the arrows and Enter included; Esc stops it listening, Backspace clears it, `shown` names the value, and ui_capturing() tells the host to leave its keys alone (through the frame that ended it). - note="..." under any control's label (.ui-labels > .ui-label + .ui-note); a range's (or number's) value with decimals, format="percent" and a unit. - A popover with `anchor="id"` (the nearest element of that id) or a bare `anchor` (the element before it) sits beside it by `placement` (right, left, bottom, top), its margin the gap, opens to the other side where it would leave the screen, and is kept on it. - A tooltip's title splits into lines at a newline or a written \n. - text-shadow, inherited, drawn sharp under the text. - ui_opacity(): the group opacity a native's draw is at. - border-image is drawn as painted with no background colour, tinted by one, and not at all when that colour is transparent (it drew a white nine-slice). - A picture file is drawn untinted, as a browser draws one; an atlas cell (prefix:name) still takes the color around it, and an <img> with its own color is tinted by it. - The render3d backend loads a picture again when its file changes or appears (a failed load was kept for ever), and at once after ui_image_reload(path); takes a path with a drive letter (C:/...) as a path rather than an atlas; and slices a nine-slice by its texture's own width and height. - ui_inputs.ludic and ui_look.ludic; LANGUAGE.md and the changeset say all of it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
60 lines
2.2 KiB
Text
60 lines
2.2 KiB
Text
# pointer.ludic - the pointer: what it is over is :hover (the element and all around it, as in CSS),
|
|
# a press on a control focuses it and makes it :active, and letting go over it is a click. The
|
|
# control being dragged (a range's thumb, a scrollbar) keeps the pointer until it is let go.
|
|
var fr_hover: []string = new []string
|
|
var fr_press_key: string = ""
|
|
var fr_down_now: bool = false
|
|
function fr_was_hovered(key: string) -> bool { return sel_has(fr_hover, key) }
|
|
function fr_pointer(root: UiNode) -> void {
|
|
let i = in_now
|
|
fr_down_now = i.down
|
|
let keys = new []string
|
|
let top = pp_top(root)
|
|
var scope = root
|
|
if top != null { scope = top }
|
|
fr_under(scope, i.x, i.y, keys)
|
|
fr_hover = keys
|
|
tt_track(scope, i.x, i.y)
|
|
if top != null and pp_pointer(top) { return }
|
|
let hit = fr_hit(scope, i.x, i.y)
|
|
if i.down and not in_was_down {
|
|
ct_key_pressed_away(hit)
|
|
fr_press_key = ""
|
|
if hit != null {
|
|
fr_press_key = hit.key
|
|
if hit.focusable { ui_focus(hit.key) }
|
|
ct_press(hit, i.x, i.y)
|
|
}
|
|
}
|
|
if i.down and fr_press_key != "" { ct_drag(root, fr_press_key, i.x, i.y) }
|
|
if not i.down and in_was_down {
|
|
if hit != null and hit.key == fr_press_key and hit.enabled { ct_activate(hit) }
|
|
fr_press_key = ""
|
|
}
|
|
}
|
|
function fr_under(n: UiNode, px: float, py: float, keys: []string) -> void {
|
|
if px < n.x or py < n.y or px >= n.x + n.cw or py >= n.y + n.ch { return }
|
|
if n.key != "" { push(keys, n.key) }
|
|
for i in 0 .. len(n.children) { fr_under(n.children[i], px, py, keys) }
|
|
}
|
|
# the deepest control (or pressable element) under the pointer
|
|
function fr_hit(n: UiNode, px: float, py: float) -> UiNode {
|
|
if px < n.x or py < n.y or px >= n.x + n.cw or py >= n.y + n.ch { return null }
|
|
var i = len(n.children) - 1
|
|
while i >= 0 {
|
|
let h = fr_hit(n.children[i], px, py)
|
|
if h != null { return h }
|
|
i -= 1
|
|
}
|
|
if n.focusable or n.act != null { return n }
|
|
return null
|
|
}
|
|
export function ui_hit(root: UiNode, px: float, py: float) -> UiNode { return fr_hit(root, px, py) }
|
|
function fr_node(n: UiNode, key: string) -> UiNode {
|
|
if n.key == key { return n }
|
|
for i in 0 .. len(n.children) {
|
|
let f = fr_node(n.children[i], key)
|
|
if f != null { return f }
|
|
}
|
|
return null
|
|
}
|