Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
400
Capture RightClick>Paste action
posted

Hi!

I would like to make some processing on the text that is pasted on my editor. I can use the KeyDown event to get pastes from the keyboard (Ctrl+V) but I cannot capture the event when it occurs by right clicking and selecting Paste with the mouse.

Can you please help?

Parents
No Data
Reply
  • 69832
    Offline posted

    I assume here that you are using an UltraTextEditor.

    Typically no distinction is made between a paste operation and a "standard" changing of the text, because in both cases the user has changed something about the value. The TextChanged event will fire in both cases (assuming that the paste operation has actually changed the text value), so if you handle that event, you will get a notification in both scenarios.

    The .NET runtime does not really expose any way to receive a notification when text is pasted, presumably because applications should not care about the way the text has changed, just that it has changed.

    A TextBox-derived control is used within the UltraTextEditor, which does in fact respond to windows messages. A WM_PASTE message is sent to this control when the user pastes text, regardless of whether it was via the keyboard or mouse. The complication is that the only way for you to receive this notification is to implement a message filter and intercept the messages before they get to the control. Personally I would evaluate how important it is for your application to know when text is being pasted before going down this road.

Children
No Data