mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 02:15:34 +00:00
ui/key: make the computed text input state available as a method
When merging the key and pointers input sources, we can't return the text input state as a side effect of the Frame method. Expose it as a method in the key event queue instead. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+12
-5
@@ -11,6 +11,7 @@ type Queue struct {
|
|||||||
focus Key
|
focus Key
|
||||||
handlers map[Key]*handler
|
handlers map[Key]*handler
|
||||||
reader ui.OpsReader
|
reader ui.OpsReader
|
||||||
|
state TextInputState
|
||||||
}
|
}
|
||||||
|
|
||||||
type handler struct {
|
type handler struct {
|
||||||
@@ -27,7 +28,13 @@ const (
|
|||||||
priNewFocus
|
priNewFocus
|
||||||
)
|
)
|
||||||
|
|
||||||
func (q *Queue) Frame(root *ui.Ops) TextInputState {
|
// InputState returns the last text input state as
|
||||||
|
// determined in Frame.
|
||||||
|
func (q *Queue) InputState() TextInputState {
|
||||||
|
return q.state
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *Queue) Frame(root *ui.Ops) {
|
||||||
if q.handlers == nil {
|
if q.handlers == nil {
|
||||||
q.handlers = make(map[Key]*handler)
|
q.handlers = make(map[Key]*handler)
|
||||||
}
|
}
|
||||||
@@ -61,13 +68,13 @@ func (q *Queue) Frame(root *ui.Ops) TextInputState {
|
|||||||
}
|
}
|
||||||
switch {
|
switch {
|
||||||
case pri == priNewFocus:
|
case pri == priNewFocus:
|
||||||
return TextInputOpen
|
q.state = TextInputOpen
|
||||||
case hide:
|
case hide:
|
||||||
return TextInputClosed
|
q.state = TextInputClosed
|
||||||
case changed:
|
case changed:
|
||||||
return TextInputFocus
|
q.state = TextInputFocus
|
||||||
default:
|
default:
|
||||||
return TextInputKeep
|
q.state = TextInputKeep
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user