app,io/router: map Androids' DPAD_CENTER to a click

Mapping it to key.NameReturn confuses widgets such as Editor that
treats clicks separate from return key presses.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2022-02-28 14:24:17 +01:00
parent 2bea9a3736
commit 21431975de
4 changed files with 31 additions and 1 deletions
+5
View File
@@ -253,6 +253,11 @@ func (q *keyQueue) Push(e event.Event, events *handlerEvents) {
}
}
func (q *keyQueue) BoundsFor(t event.Tag) f32.Rectangle {
order := q.handlers[t].dirOrder
return q.dirOrder[order].bounds
}
func (q *keyQueue) setFocus(focus event.Tag, events *handlerEvents) {
if focus != nil {
if _, exists := q.handlers[focus]; !exists {
+17
View File
@@ -152,6 +152,23 @@ func (q *Router) MoveFocus(dir FocusDirection) {
q.key.queue.MoveFocus(dir, &q.handlers)
}
func (q *Router) ClickFocus() {
focus := q.key.queue.focus
if focus == nil {
return
}
bounds := q.key.queue.BoundsFor(focus)
center := bounds.Max.Add(bounds.Min).Mul(.5)
e := pointer.Event{
Position: center,
Source: pointer.Touch,
}
e.Type = pointer.Press
q.pointer.queue.Push(e, &q.handlers)
e.Type = pointer.Release
q.pointer.queue.Push(e, &q.handlers)
}
// TextInputState returns the input state from the most recent
// call to Frame.
func (q *Router) TextInputState() TextInputState {