I have overridden an Entry to deal with a tab keypress in a fyne Table. My aim is to finish editing and go to the next cell when the Tab key is pressed, just like in Excel. However it seems like Tab is absorbed by the framework. Other keys like arrows and enter are picked up by my TypeKey event handler, as I have observed from the fmt.Println("TypedKey", event.Name) at the start of the event handler.
Currently my OnSubmitted event handler is only called when Enter is pressed, and not tab. Tab just seems to finish editing and switch to the Label without calling OnSubmitted.
Here is the code for the overidden Entry:
type EditingEntry struct {
widget.Entry
OnTab func()
}
func NewEditingEntry() *EditingEntry {
e := &EditingEntry{}
e.ExtendBaseWidget(e)
return e
}
func (e *EditingEntry) TypedKey(event *fyne.KeyEvent) {
fmt.Println("TypedKey", event.Name)
if event.Name == fyne.KeyTab {
if e.OnTab != nil {
e.OnTab()
}
return
}
e.Entry.TypedKey(event) // Call base behavior
}
I am using version fyne.io/fyne/v2 v2.6.1 on Ubuntu linux 22.04.5, with XWindows, KDE. The Table uses widget.Stack for the cells, which contains widget.Label for the non-editing cells and EditingEntry for the editing cell.