feat(ui): a title shows for the keyboard's focus as well as the pointer
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
d15cc79822
commit
077b38e684
9 changed files with 78 additions and 12 deletions
|
|
@ -80,5 +80,5 @@ function fr_outline(n: UiNode) -> void {
|
|||
ui_be.ring(n.x - o, n.y - o, n.cw + o * 2.0, n.ch + o * 2.0, n.radius + o, n.outline_w, c, a)
|
||||
return
|
||||
}
|
||||
fr_frame(n.x - o, n.y - o, n.cw + o * 2.0, n.ch + o * 2.0, n.outline_w, c, a)
|
||||
if ui_be.rect != null { fr_frame(n.x - o, n.y - o, n.cw + o * 2.0, n.ch + o * 2.0, n.outline_w, c, a) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ export function ui_show(screen: string, view: UiView, x: float, y: float, w: flo
|
|||
sc_update(root)
|
||||
fr_pointer(root)
|
||||
fc_keys(root)
|
||||
tt_track(root, in_now.x, in_now.y)
|
||||
if ui_be != null and ui_be.text != null {
|
||||
fr_draw(root)
|
||||
pp_draw_top()
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ function fr_pointer(root: UiNode) -> void {
|
|||
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 }
|
||||
if sc_drag != "" or ct_key_mouse(root) { return }
|
||||
let hit = fr_hit(scope, i.x, i.y)
|
||||
|
|
|
|||
|
|
@ -1,13 +1,23 @@
|
|||
# tooltip.ludic - an element's title="..." shown beside the pointer once it has rested on the
|
||||
# element for half a second, in a box styled by .ui-tooltip (the default sheet's, or a theme's); a
|
||||
# title of several lines (a newline, or \n) is one .ui-tooltip-text a line
|
||||
# tooltip.ludic - an element's title="..." shown beside the pointer once it has rested on it for half
|
||||
# a second (or under it, when the keyboard's focus has), in a box styled by .ui-tooltip; a title of
|
||||
# several lines (a newline, or \n) is one .ui-tooltip-text a line
|
||||
var tt_key: string = ""
|
||||
var tt_since: float = 0.0
|
||||
var tt_text: string = ""
|
||||
var tt_x: float = 0.0
|
||||
var tt_y: float = 0.0
|
||||
function tt_track(scope: UiNode, x: float, y: float) -> void {
|
||||
let n = tt_under(scope, x, y)
|
||||
function tt_track(root: UiNode, x: float, y: float) -> void {
|
||||
var scope = pp_top(root)
|
||||
if scope == null { scope = root }
|
||||
var n = tt_under(scope, x, y)
|
||||
var px = x
|
||||
var py = y
|
||||
let k = tt_focused(scope, x, y)
|
||||
if k != null {
|
||||
n = k
|
||||
px = k.x
|
||||
py = k.y + k.ch - ui_px(14.0)
|
||||
}
|
||||
if n == null {
|
||||
tt_key = ""
|
||||
return
|
||||
|
|
@ -17,8 +27,8 @@ function tt_track(scope: UiNode, x: float, y: float) -> void {
|
|||
tt_since = an_now()
|
||||
}
|
||||
tt_text = tt_translate(n, ui_attr_text(n, "title"))
|
||||
tt_x = x
|
||||
tt_y = y
|
||||
tt_x = px
|
||||
tt_y = py
|
||||
}
|
||||
# the deepest element under the point that has a title
|
||||
function tt_under(n: UiNode, x: float, y: float) -> UiNode {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,17 @@
|
|||
# tooltip_text.ludic - a title in the program's language: the whole of it when the translator knows
|
||||
# it, else line by line; and not at all inside translate="no" (the nearest translate= out from it)
|
||||
# tooltip_text.ludic - a title in the program's language (whole when the translator knows it whole,
|
||||
# else line by line, and not inside translate="no"), and a title for the keyboard's focus
|
||||
var tt_by_keys: bool = false # the focus moved by the keyboard since the pointer last moved
|
||||
var tt_focus_seen: string = ""
|
||||
# the focused element, when the keyboard put the focus there and it has a title; else null
|
||||
function tt_focused(scope: UiNode, x: float, y: float) -> UiNode {
|
||||
if in_last.x != x or in_last.y != y { tt_by_keys = false }
|
||||
if fc_visible and fc_key != "" and fc_key != tt_focus_seen { tt_by_keys = true }
|
||||
tt_focus_seen = fc_key
|
||||
if not tt_by_keys or not fc_visible { return null }
|
||||
let n = fr_node(scope, fc_key)
|
||||
if n == null or n.akeys == null or ui_attr_text(n, "title") == "" { return null }
|
||||
return n
|
||||
}
|
||||
function tt_translate(n: UiNode, s: string) -> string {
|
||||
var at = n
|
||||
while at != null {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue