I want to trap when the user drops (pastes) text from outside of my app. The TextArea has AcceptTextDrop in its Open event so the drop works.
Is there an event similar to DropObject (which doesn’t fire for a simple text drop) or do I have to watch the TextChange event and intercept the text dropped there while distinguishing between the change from the drop and a change from editing by the user?
Create a subclass of text area
Then you can implement DropObject (and several other things that if you just drop an instance on a layout you cant override)
I guess I’m missing something. My first question here is should the TextArea’s KeyDown event handler see a Ctrl-V as something it is supposed to deal with? I created a new project with nothing in the window except a TextArea control. The only code I added was a Break in the KeyDown event. I then copied some text from a NotePad file and used Ctrl-V to paste it into the TextArea. It pasted in fine but the KeyDown event never hit the Break statement. I then put a Breakpoint on the Break statement and tried again. Still nothing except the text showing in the TextArea.
So now I’m really confused. It’s as if the KeyDown event isn’t even firing. Is it supposed to in a case like this?
The KeyDown event will never see the Ctrl-V keypress because it is handled by the standard EditPaste menu handler. In a subclass, as Norman suggests, you can implement your own EditPaste handler and catch it there.