-
-
Notifications
You must be signed in to change notification settings - Fork 328
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 support for pasting text into a textbox #2281
Add support for pasting text into a textbox #2281
Conversation
d5df70c
to
b2d9b06
Compare
I was a bit worried this would paste multiple times even on press but it seems fine to me. It behaves pretty much the same as the textbox on github does for me, i.e. paste - pause - repeat pastes with ctrl+v held down. It might be good to check on windows and mac as well though. For testing we could do something similar to the camera and mouse state machine tests in https://github.com/MakieOrg/Makie.jl/blob/master/test/events.jl. I.e. create a figure with a textbox, trigger some events to select it, fill the clipboard with something (you can pass content to it) trigger down+release of |
Hi @ffreyer For the test I'm using a mouse click to simulate the textbox being selected. Another issue is that I clear the figure and recreate the scene to test the right control + v combination. But the test fails for this attempt, and I don't know why: it always evaluates the Would you mind taking a look? |
I don't think display should be necessary. Maybe you need remove either the |
Yes, the Without Is there a more straightforward way to selecting widgets programmatically that I'm not aware of? |
I cleaned up the tests, they should be working now.
There are multiple sources for the window size which can be used. |
Is it worth setting one of those up to test this? |
I guess it would be good for completeness, but I'll have to leave this up to you as I don't run *nix at the moment. Sorry! |
src/makielayout/blocks/textbox.jl
Outdated
if is_allowed(char, tbox.restriction[]) | ||
insertchar!(char, cursorindex[] + 1) | ||
else | ||
no_err = false |
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 doesn't really seem like an error case, so I'd rather call this all_chars_allowed
or something like that.
Also, we should add a catch case and rethrow, no? Or at least warn...
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.
Excuse the clumsy implementation.
My thinking here was that it would be obvious that the copy/paste stopped.
I take your point, though, it would make more sense if I check for disallowed characters in the string first, and just abort the paste if any is found. Will make changes in the morning
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.
No worries, this is great :) Maybe just use:
if all(char-> is_allowed(char, tbox.restriction[]), content)
foreach(char-> insertchar!(char, cursorindex[] + 1), content)
return Consume(true)
else
return Consume(true)
end
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.
Thanks!
That second Consume
returns false
instead though, correct? But yes, I get the idea.
Warn when pasting fails Check all characters are allowed before pasting, otherwise abort.
Thanks :) |
Support pasting text into a textbox.
Fixes #2266
Type of change
Delete options that do not apply:
Checklist