-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Intercepting Paste Events #1177
Comments
Just a possible solution, not a permanent one: you could copy the code of this file and remove the linked lines to create a widget which doesn't handle pasting, or just insert your custom logic into that area iced/native/src/widget/text_input.rs Lines 680 to 710 in 5466d6a
|
ooh that's handy, thank you!
…On Fri, Dec 31 2021 at 01:33:17 PM -0800, Caden Haustein ***@***.***> wrote:
Just a possible solution, not a permanent one: you could copy the
code of this file and remove the linked lines to create a widget
which doesn't handle pasting, or just insert your custom logic into
that area
<https://github.com/iced-rs/iced/blob/5466d6a11d0a4bee01e954b7c727b3fd67cea02a/native/src/widget/text_input.rs#L680-L710>
—
Reply to this email directly, view it on GitHub
<#1177 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AJIYMMPRKDXFVCHXZDTGMADUTYOR3ANCNFSM5LBV4UIA>.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
We could extend the Could you elaborate a bit on your use case? Do you want to simply perform a transformation on the pasted text? |
Sorry I didn't get back to this sooner! The project I'm working on is displaying several lines of text in a context where it makes sense to use individual, single-line text inputs. However, I'd like the user to be able to do a multi-line paste, so I'm trying to fudge it a little bit by intercepting the paste and breaking up the text between lines. That said, I could definitely see this being used in other usecases where transformations might need to be applied as well. |
I'm trying to write an app which includes custom behavior for pasting, and especially multi-line pasting. It's fairly easy to listen for a Ctr+V event, check if a relevant input is selected, grab the clipboard, and then run the custom behavior.
However, by the time the message reaches my code, the UI will have already filled the widget with the text clipboard. I can work around this by just guessing the length of the pasted text (i think it's just the text length - the # of newlines) and truncating the text in the UI, but this feels a little messy.
It would be nice to be able to intercept a paste event, maybe by setting a property on the
TextInput
component that produces aMessage
instead of pasting text, or just disabling pasting into theTextInput
.The text was updated successfully, but these errors were encountered: