~eliasnaur/gio

28dd25736f35432850bf5c2df8187315587bcbaa — Elias Naur 2 years ago bb6ee05
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>
1 files changed, 12 insertions(+), 5 deletions(-)

M ui/key/queue.go
M ui/key/queue.go => ui/key/queue.go +12 -5
@@ 11,6 11,7 @@ type Queue struct {
	focus    Key
	handlers map[Key]*handler
	reader   ui.OpsReader
	state    TextInputState
}

type handler struct {


@@ 27,7 28,13 @@ const (
	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 {
		q.handlers = make(map[Key]*handler)
	}


@@ 61,13 68,13 @@ func (q *Queue) Frame(root *ui.Ops) TextInputState {
	}
	switch {
	case pri == priNewFocus:
		return TextInputOpen
		q.state = TextInputOpen
	case hide:
		return TextInputClosed
		q.state = TextInputClosed
	case changed:
		return TextInputFocus
		q.state = TextInputFocus
	default:
		return TextInputKeep
		q.state = TextInputKeep
	}
}