You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is kind of a follow-up to #1737 : more edge cases for cursor positioning for entries with wrapping enabled.
Suppose you have a multiline entry with word wrapping enabled. Some user actions move the cursor into an unexpected position. I've observed two problems, probably with the same underlying issue, thus I'm reporting them jointly:
Erasing the first symbol
Put the cursor after the first symbol on some line in a multiline entry with wrapping. Any line except the very first one would work. Pressing backspace erases the symbol, but then moves the cursor to the start of the next line instead of staying in the same line.
The additional cursor movement happens due to the rowColFromTextPos function in entry.go, specifically in this part:
This part of logic was created to fix #1737, but I guess it is executed in some undesirable cases too.
Space key in a word-wrapped entry
In a word-wrapping entry, sometimes pressing the space character creates a new (visual) line of text. In some cases at this moment cursor also moves one more row down than expected: instead of being moved to the new visual line, it's being put one line after that.
It's easiest to reproduce by putting the cursor at the beginning of the last word on some line, and then pressing space enough times to move that word to the next visual line. You would see that the cursor is no longer at the beginning of that word but rather in the next line after it. It's also relatively easy to reproduce by typing a space in the middle of a long word in a way that the second part of the word no longer fits visually after the space character. Then the cursor would also jump two lines down instead of only one.
To Reproduce:
Steps to reproduce the behavior:
Compile the example code below and run it.
To see the issue with space character, just press space. The long word would split into two and the cursor would jump two lines down.
To see the issue with erasing one character, press backspace several time until you erase the first symbol. You will see the cursor move one line down. Alternatively, just put the cursor so that pressing backspace would erase the first symbol of some line for the same result.
Example code:
package main
import (
"time""fyne.io/fyne/v2""fyne.io/fyne/v2/app""fyne.io/fyne/v2/widget"
)
funcmain() {
app:=app.New()
w:=app.NewWindow("Multiline entry demo")
entry:=widget.NewMultiLineEntry()
entry.Wrapping=fyne.TextWrapWordentry.SetText("abc\ns\ndefsfdsfsdffd\nf hh\n")
w.SetContent(entry)
w.Resize(fyne.NewSize(float32(120), float32(150)))
w.Canvas().Focus(entry)
gofunc() {
// NB: the window (hence the entry as well) is tiny when just created,// which causes excessive wrapping in the entry. Calling w.Resize() does not// resize the entry immediately, so we set cursor position only after a delay.// I don't know if this is considered a bug, but it's a bit surprising.time.AfterFunc(200*time.Millisecond, func() {
entry.CursorRow=2entry.CursorColumn=7entry.Refresh()
})
}()
w.ShowAndRun()
}
Device (please complete the following information):
OS: Linux
Version: PopOS 21.04
Go version: go1.17.4 linux/amd64
Fyne version: v2.1.2
The text was updated successfully, but these errors were encountered:
Describe the bug:
This is kind of a follow-up to #1737 : more edge cases for cursor positioning for entries with wrapping enabled.
Suppose you have a multiline entry with word wrapping enabled. Some user actions move the cursor into an unexpected position. I've observed two problems, probably with the same underlying issue, thus I'm reporting them jointly:
Erasing the first symbol
Put the cursor after the first symbol on some line in a multiline entry with wrapping. Any line except the very first one would work. Pressing backspace erases the symbol, but then moves the cursor to the start of the next line instead of staying in the same line.
The additional cursor movement happens due to the
rowColFromTextPos
function inentry.go
, specifically in this part:fyne/widget/entry.go
Lines 910 to 912 in 6c35798
This part of logic was created to fix #1737, but I guess it is executed in some undesirable cases too.
Space key in a word-wrapped entry
In a word-wrapping entry, sometimes pressing the space character creates a new (visual) line of text. In some cases at this moment cursor also moves one more row down than expected: instead of being moved to the new visual line, it's being put one line after that.
It's easiest to reproduce by putting the cursor at the beginning of the last word on some line, and then pressing space enough times to move that word to the next visual line. You would see that the cursor is no longer at the beginning of that word but rather in the next line after it. It's also relatively easy to reproduce by typing a space in the middle of a long word in a way that the second part of the word no longer fits visually after the space character. Then the cursor would also jump two lines down instead of only one.
To Reproduce:
Steps to reproduce the behavior:
Example code:
Device (please complete the following information):
The text was updated successfully, but these errors were encountered: