We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
fyne-io
andydotxyz
Jacalz
dweymouth
toaster
Learn more about funding links in repositories.
Report abuse
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pretty much the title, fairly simple bug I think. The single line entry will discard any selected text on submit.
With a single line entry:
No response
package main import ( "fmt" "image/color" "fyne.io/fyne/v2" "fyne.io/fyne/v2/app" "fyne.io/fyne/v2/canvas" "fyne.io/fyne/v2/container" "fyne.io/fyne/v2/theme" "fyne.io/fyne/v2/widget" ) func main() { application := app.NewWithID("test-gui") window := application.NewWindow("Test GUI") monospace := fyne.MeasureText("M", theme.TextSize(), fyne.TextStyle{Monospace: true}) min := canvas.NewRectangle(color.RGBA{}) min.SetMinSize(fyne.NewSize(monospace.Width*20, monospace.Height*5)) entry := widget.NewEntry() label := widget.NewLabel("") entry.OnSubmitted = func(v string) { label.SetText(fmt.Sprintf("%q", v)) } window.SetContent(container.NewMax(min, container.NewGridWithRows(2, entry, label))) window.Show() application.Run() }
develop
1.20.5
Windows 11
The text was updated successfully, but these errors were encountered:
This patch seems to fix the problem, but I don't really know if it's the correct approach:
diff --git a/widget/entry.go b/widget/entry.go index 41967616e..5ada3d289 100644 --- a/widget/entry.go +++ b/widget/entry.go @@ -1028,7 +1028,9 @@ func (e *Entry) selectingKeyHandler(key *fyne.KeyEvent) bool { return true case fyne.KeyReturn, fyne.KeyEnter: // clear the selection -- return unhandled to add the newline - e.eraseSelection() + if e.MultiLine { + e.eraseSelection() + } return false }
Sorry, something went wrong.
Good catch. A sensible fix - though it would need unit tests as well to confirm fix and avoid regressions.
widget: Single line Entry: Submit should include selected text. (fyne…
bae1741
…-io#4026)
Added multi line test to ensure no behaviour change from fixing (fyne…
aa86bfe
Merge pull request #4028 from Goltanju/issue4026
b982de1
widget: Single line Entry: Submit should include selected text. (#4026)
Fix landed on develop, thanks so much @Goltanju
No branches or pull requests
Checklist
Describe the bug
Pretty much the title, fairly simple bug I think. The single line entry will discard any selected text on submit.
How to reproduce
With a single line entry:
Screenshots
No response
Example code
Fyne version
develop
Go compiler version
1.20.5
Operating system and version
Windows 11
Additional Information
No response
The text was updated successfully, but these errors were encountered: