~whereswaldon/rosebud

c9e3fd464d78db05baa44fa5822bab78220ad973 — Chris Waldon 1 year, 2 months ago 743da9f
appwidget: do not accept focus on editor wrapper

This commit ensures that the extra event handling wrapping our editor does
not accept focus, but instead passes it on to the nested editor. Otherwise
one needs to press tab twice to transfer focus into the editor.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
1 files changed, 8 insertions(+), 3 deletions(-)

M appwidget/tx-editor.go
M appwidget/tx-editor.go => appwidget/tx-editor.go +8 -3
@@ 170,7 170,7 @@ func (e *TxEditor) ResolveSuggestionCreate(createdTag string) {
// processBodyEvents is used to respond to interactions with the editor for
// the entity's body text. It expects a copy of all key events routed to
// the editor.
func (e *TxEditor) processBodyEvents(keyEvents []event.Event) []event.Event {
func (e *TxEditor) processBodyEvents(keyEvents []event.Event, self bool) []event.Event {
	for i := 0; i < len(keyEvents); i++ {
		event := keyEvents[i]
		var dropEvent bool


@@ 179,6 179,11 @@ func (e *TxEditor) processBodyEvents(keyEvents []event.Event) []event.Event {
			if !event.Focus {
				e.suggesting = false
			}
			if event.Focus && self {
				// If we received focus as the wrapper suggestion widget layer, pass focus
				// to the nested editor.
				e.Editor.Focus()
			}
		case key.Event:
			switch event.Name {
			case key.NameEscape:


@@ 242,8 247,8 @@ func (e *TxEditor) Layout(gtx C, editor layout.Widget) D {
	tag := e.Editor.KeyTag()
	editorKeys := gtx.Events(tag)
	ourKeys := gtx.Events(e)
	editorKeys = e.processBodyEvents(editorKeys)
	e.processBodyEvents(ourKeys)
	editorKeys = e.processBodyEvents(editorKeys, false)
	e.processBodyEvents(ourKeys, true)

	key.InputOp{
		Tag:  e,