Handling User Paste in TEdit lazarus / 31-LCL ---------------------------------------------------------------------- 99Percent · 2011-11-05 18:12 Lets say we have a TEdit component that should only have numeric characters 0..9. I can trap keystrokes that aren't numeric with the OnKeyPress event, converting them to #0 easily enough. But if the user copies and paste text, the TEdit object will accept all the characters. I can intercept the Ctrl-V and then filter the Clipboard.Text accordingly, but I don't see how I can intercept a mouse paste. Somewhere in the object, LCL is accepting this input into the textbox, but I can't see how. An OnPaste (even better, OnBeforePaste and OnAfterPaste) would be very convenient to have as properties no? ---------------------------------------------------------------------- Avishai · 2011-11-05 18:17 Can you use the OnChange event?  I did not try, but I think it can work. ---------------------------------------------------------------------- souppatin · 2011-11-22 08:58 have you try OnContextPopup ? ---------------------------------------------------------------------- zeljko · 2011-11-22 09:57 And what if user paste something via middle button (X11 selection) , how will you intercept Ctrl+V ? ---------------------------------------------------------------------- BigChimp · 2011-11-22 12:59 What about being more relaxed and allowing all kinds of pasting - users can still change what they type while editing, anyway. Then use OnEditingDone with a message to restrict the kind of values that are allowed. Personnally, I hate fields such as telephone number edits that disallow the + symbol. If I want to paste a number with +, I can't, so I have to edit it elsewhere and then paste it. ---------------------------------------------------------------------- Bart · 2011-11-23 12:07 If the length of the text in the TEdit you expect allows for it, you can use a TMaskEdit with a mask like '999999999999999' This will allow up to 15 "digits" in th econtrol. It also handles past actions. Bart