diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2024-11-10 20:45:40 +0100 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2024-11-10 20:45:40 +0100 |
commit | ad61b790fdef156179b843e439be28613369ded7 (patch) | |
tree | 7a651ca7d44007b0fff6c3a1e2a062031fd59804 | |
parent | 6a8db1f41253d11c829dbe7d1d76722aa3fa8772 (diff) | |
download | xK-ad61b790fdef156179b843e439be28613369ded7.tar.gz xK-ad61b790fdef156179b843e439be28613369ded7.tar.xz xK-ad61b790fdef156179b843e439be28613369ded7.zip |
WIP: xA: entry modifiers
-rw-r--r-- | xA/xA.go | 25 |
1 files changed, 24 insertions, 1 deletions
@@ -979,23 +979,31 @@ func inputSubmit(text string) bool { type customEntry struct { widget.Entry + + // selectKeyDown is a hack to exactly invert widget.Entry's behaviour, + // which groups both Shift keys together. selectKeyDown bool + + down map[fyne.KeyName]bool } func newCustomEntry() *customEntry { e := &customEntry{} e.MultiLine = true e.Wrapping = fyne.TextWrap(fyne.TextTruncateClip) + e.down = make(map[fyne.KeyName]bool) e.ExtendBaseWidget(e) return e } func (e *customEntry) FocusLost() { + e.down = make(map[fyne.KeyName]bool) e.selectKeyDown = false e.Entry.FocusLost() } func (e *customEntry) KeyDown(key *fyne.KeyEvent) { + e.down[key.Name] = true if key.Name == desktop.KeyShiftLeft || key.Name == desktop.KeyShiftRight { e.selectKeyDown = true } @@ -1003,6 +1011,7 @@ func (e *customEntry) KeyDown(key *fyne.KeyEvent) { } func (e *customEntry) KeyUp(key *fyne.KeyEvent) { + delete(e.down, key.Name) if key.Name == desktop.KeyShiftLeft || key.Name == desktop.KeyShiftRight { e.selectKeyDown = false } @@ -1014,6 +1023,19 @@ func (e *customEntry) TypedKey(key *fyne.KeyEvent) { return } + /* + modified := false + for _, name := range []fyne.KeyName{ + desktop.KeyAltLeft, desktop.KeyAltRight, + desktop.KeyControlLeft, desktop.KeyControlRight, + desktop.KeySuperLeft, desktop.KeySuperRight, + } { + if e.down[name] { + modified = true + } + } + */ + // Invert the Shift key behaviour here. // Notice that this will never work on mobile. shift := &fyne.KeyEvent{Name: desktop.KeyShiftLeft} @@ -1027,7 +1049,8 @@ func (e *customEntry) TypedKey(key *fyne.KeyEvent) { e.OnSubmitted(e.Text) } case fyne.KeyTab: - // TODO(p) + // TODO(p): Just do e.Append() if state matches. + log.Println("completion") default: e.Entry.TypedKey(key) } |