-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
add StartSelect Collumn and Row in entry #5403
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This naming is misleading - it reads like the verb "Start" rather than a noun / getter.
Also given that there are cursor fields for position should this not match?
I'm not certain of the use-case which is important to get the naming right. The issue you referenced just pointed out the lack it did not actually describe what is trying to be achieved.
@andydotxyz People who want to get the starting point of the text selection will not be able to get it. I think it would be better if they had a method that would give them this opportunity. |
Is it possible to expand on the use-case? "Needing to access the variable" doesn't tell us much about why - and because Fyne naming tries to be focused on outcomes then it may be important. Also there may even be an easier way to do the thing you're trying to achieve! |
@andydotxyz okey. in one of the project I added and refactored the ability in the "text editor" to change the "parameters" of the text by pressing a button. And I found the fact that I can't "out of the box" take the "beginning of the selection", and I had to implement it through available paths. But it was very difficult and unpleasant, after which I decided to make the selectRow and selectColumn fields private Do I understand correctly that the problem is not only in the implementation, but also in the lack of understanding of the need? |
“start of selection” is what I need to insert in front of the text a text tag specific for display (local text engine for the project, like Markdown) |
Yea trying to understand the need is key ("use-case"). |
@andydotxyz here is a regular entry window. And in it I selected text. There is a point where I started to select it and finished. The position where I finished selecting can be found out using "entry.SelectRow" "entry.SelectColumn" In my case, it will be "row:0 column:1", "row:3 column:3" respectively |
Yes thanks I understand exactly what you are describing as start of selection - but I'm still it grasping what you're looking to do - text manipulations and selection handling are complex for sure. In 2.6 we have "InsertAtCursor" and if you send it "textToInsert" + Entry.SelectedText() then it will inset the string at the beginning of the selection. Is that what you're trying to do? |
@andydotxyz no, using the method you indicated, we can't insert text BEFORE starting to select text Or is there something I don't understand anymore? |
Maybe have sense create just method for it (insert text before "start pos")? |
Let's pin this down to more concrete chat. How does what you want to do differ from: func Test_InsertBefore(t *testing.T) {
test.NewTempApp(t)
initial := widget.NewEntry()
initial.SetText("abcdef")
right := &fyne.KeyEvent{
Name: fyne.KeyRight,
}
initial.TypedKey(right)
initial.TypedKey(right)
initial.KeyDown(&fyne.KeyEvent{
Name: desktop.KeyShiftLeft,
})
initial.TypedKey(right)
initial.TypedKey(right)
initial.KeyUp(&fyne.KeyEvent{
Name: desktop.KeyShiftLeft,
})
if initial.SelectedText() != "cd" {
t.Fail()
}
initial.InsertAtCursor("12cd")
if initial.Text != "ab12cdef" {
t.Fail()
}
} |
@andydotxyz yes, the logic is very close, but in this case, we inserted the text at the cursor location, although we started selecting in a different place (we started selecting from the end, but inserted it almost at the beginning of the text) +it's a replace of the text, if I'm right understand |
Sorry I don't understand this message. The unit test I pasted replaces the selected text with alternative text which is the selection plus some other text - so it could be added at the beginning or the end. Does that help? |
There is no way, so to speak, to insert text at the same time and the end, and in the beginning of the text (without the help of external means). When we have seen the text, we can find the point where we stopped selecting, but not where we started CursorRow - the place where we stopped highlighting, but where we started selected, we have no way of knowing this place |
Forgive me, but doesn't this code very that scenario? func Test_InsertBefore(t *testing.T) {
test.NewTempApp(t)
initial := widget.NewEntry()
initial.SetText("123456")
right := &fyne.KeyEvent{
Name: fyne.KeyRight,
}
initial.TypedKey(right)
initial.TypedKey(right)
initial.KeyDown(&fyne.KeyEvent{
Name: desktop.KeyShiftLeft,
})
initial.TypedKey(right)
initial.TypedKey(right)
initial.KeyUp(&fyne.KeyEvent{
Name: desktop.KeyShiftLeft,
})
if initial.SelectedText() != "34" {
t.Fail()
}
initial.InsertAtCursor("start34stop")
if initial.Text != "12start34stop56" {
t.Fail()
}
} |
Description:
Fixes #5402
Checklist:
Need i for it test?