widget: no newline in editor on submit

When you press enter to "submit" an editor widget, don't also append the
newline to the editor text.  Enter should be "submit" or "add newline"
but not both.

Also add parens to the Enter check: x && y || z => x && (y || z).

Signed-off-by: Larry Clapp <larry@theclapp.org>
This commit is contained in:
Larry Clapp
2019-11-10 16:02:11 -05:00
committed by Elias Naur
parent 682d2810d3
commit a770a2425c
+2 -1
View File
@@ -153,11 +153,12 @@ func (e *Editor) processKey(gtx *layout.Context) {
if !e.focused {
break
}
if e.Submit && ke.Name == key.NameReturn || ke.Name == key.NameEnter {
if e.Submit && (ke.Name == key.NameReturn || ke.Name == key.NameEnter) {
if !ke.Modifiers.Contain(key.ModShift) {
e.events = append(e.events, SubmitEvent{
Text: e.Text(),
})
return
}
}
if e.command(ke) {