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
View.Line() does not return entered line of text #54
Comments
You are right, looks like a bug. I'll try to fix it as soon as possible. On the other hand, I want to rewrite the edition mode from scratch and this bug is quite related, so it should be addressed as soon as the new edition mode is in place. Thanks for reporting it! |
I came across the same problem today, the problem seems to be that the handlers are executed after the key was already put in to the field, hence it reads the last (now empty) line. It would be great if handlers were called before any other action happens and - even better - if they could prevent further actions (as in not putting them in the edit-field). |
@tkausl is right. After 76554e4 handlers are executed before edition (for key events) and after mouse actions. However I'm not sure about preventing further actions... In that case, it would be better to use a non-editing keybinding or setting What do you think? |
Looks good for a start |
Greetings,
I may have stumbled across a bug, otherwise requesting clarification :-)
Here goes:
I need to implement a simple text entry, this is done inside a
View
. Just 1 line of text entry is desired - think a password / IP address / hostname etc., something short.I implemented this using the
View.Editable = true
functionality so that a user can comfortably enter text. Wrote a handler for the Enter key in order to handle OK / submit.Try running it, enter some text, press Enter.
In the handler, tried to get the entered text using view.Line(0), but ... the resulting string is empty.
But, when I enter some text, then press left arrow key a few times = move cursor into middle of entered text, then press the Enter key, then
view.Line(0)
returns everything right of the cursor.From the documentation and the name of the function (
Line
) I would expect to receive the whole line of text, not just what is right of the cursor.Is this a bug or am I understanding the use of this function wrong?
Sure, using
view.Buffer()
returns everything and this is a possible workaround in this case - but then how does one get a specific line if there are multiple lines? That use case will show up soon. I would expectview.Line(i)
to cover that functionality. As in give me the view's i-th line in the internal buffer.Example code for cut and paste:
The text was updated successfully, but these errors were encountered: