New issue
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
Pointer and cursor misalignment in widget.Entry #1937
Comments
I think the method is more wrong than you realise. Can you try the following replacement and see what you think? func (e *Entry) cursorColAt(text []rune, pos fyne.Position) int {
for i := 0; i < len(text); i++ {
str := string(text[0 : i])
wid := fyne.MeasureText(str, theme.TextSize(), e.textStyle()).Width
charWid := fyne.MeasureText(string(text[i]), theme.TextSize(), e.textStyle()).Width
if pos.X < theme.Padding()*2 + wid + (charWid/2) {
return i
}
}
return len(text)
} |
It is OK and I think we should go with it. |
If you change the offset by |
I now have a magnifying glass out to see it. the each 'i' and space between the 'ii' on my 1920x1080 monitor is 2 pixels. The pointer vertical is 1 pixel wide. I tried |
Using
|
Applying the updated maths for finding characters. Fixes fyne-io#1937
I placed that fix on |
Applying the updated maths for finding characters. Fixes #1937
Describe the bug:
I noticed that selecting around "i" is difficult in Entry. Looking at the code I can see a mistake
themePadding()
is being added towid
and added topos.X
in the if statement. This effectively cancels outtheme.Padding()
It should only be added to wid and not added in the if statement.
To Reproduce:
Steps to reproduce the behaviour:
In the Demo select the Entry tab and enter "wiiw" then repeatedly click along the first "w". You will see that the cursor will jump to before the first "i" 1/2 way along the "w".
Place your pointer between the two "ii" and click, the cursor will jump to after the second "i"
Slowly move the pointer back over the first "i" while clicking. The cursor will jump to the beginning of the first "i" when the pointer is over the second half of the "w"
With the
theme.Padding()
removed from if statementThe cursor will jump to where the pointer is. i.e. if it is between the "ii" then it will be placed between them.
Device (please complete the following information):
The text was updated successfully, but these errors were encountered: