diff --git a/packages/ludic.ui/controls_build.ludic b/packages/ludic.ui/controls_build.ludic index fd21f0a4..f87c4d0d 100644 --- a/packages/ludic.ui/controls_build.ludic +++ b/packages/ludic.ui/controls_build.ludic @@ -105,6 +105,10 @@ function ct_numeric(v: Val) -> bool { return Value.kind(v) == 1 or Value.kind(v) function ct_option_num(nv: Val, opts: []UiNode) -> int { let x = Value.as_float(nv) for i in 0 .. len(opts) { + if not ui_attr_has(opts[i], "value") { + if x == float(i) { return i } + continue + } let ov = ui_attr(opts[i], "value") if Value.kind(ov) == 0 and x == float(i) { return i } if ct_numeric(ov) and Value.as_float(ov) == x { return i } diff --git a/packages/ludic.ui/native.ludic b/packages/ludic.ui/native.ludic index cf36efb0..a659b445 100644 --- a/packages/ludic.ui/native.ludic +++ b/packages/ludic.ui/native.ludic @@ -97,11 +97,11 @@ function nt_run(ui_st: mut UiState, n: UiNode, name: string, value: Val) -> void } # an attribute of an element, as the template gave it (null when it has none) - for a native export function ui_attr(n: UiNode, key: string) -> Val { - if n.akeys == null { return Value.null() } + if n.akeys == null { return n.none } for i in 0 .. len(n.akeys) { if n.akeys[i] == key { return n.vals[i] } } - return Value.null() + return n.none } # whether an element has the attribute at all: ui_attr's miss is a new null, so a question asked # every frame asks this first diff --git a/packages/ludic.ui/node.ludic b/packages/ludic.ui/node.ludic index 48cc2dac..6bbae5c0 100644 --- a/packages/ludic.ui/node.ludic +++ b/packages/ludic.ui/node.ludic @@ -56,6 +56,7 @@ export property UiNode { nowrap: bool = false # white-space: nowrap ellipsis: bool = false # text-overflow: ellipsis lines: []string = null # a wrapped text's lines + none: Val = Value.null() # what ui_attr answers for an attribute it lacks: made with the node, read only var_names: []string = null # its custom properties (--name), which its descendants inherit var_vals: []string = null fg: int = -1 # a colour is 0xRRGGBB with its alpha beside it; -1 inherits