Copy and paste in entry field - prevented by long values on clipboard

I want to insert text into entry with hotkey ctrl + v (using copy and paste)
The control has the @s10 mask and accepts no text longer than 10 characters. Entry is empty if copied text is longer then 10 characters.
How to insert the first 10 characters of long text?
I want to fix it on every entry control in my app.
How to fix abwindow.clw?

ABWindow would be a great place to implement the changes, best to derive your own, but start by experimenting in one Window procedure.

Maybe ALRT(CtrlV) on the WINDOW. In EVENT:PreAlertKey check if the field with focus is an ENTRY so can be pasted into

OF EVENT:PreAlertKey   !Window Events
   IF KEYCODE()=CtrlV THEN
      CASE FOCUS(){PROP:Type}   !Can control take paste?
      OF   Create:Entry 
      OROF Create:Text OROF Create:Single 
      OROF Create:Combo  
      OROF Create:Spin  !?? do spin ??
         CHANGE(FOCUS(),CLIPBOARD())     !should truncate ?
         FOCUS(){PROP:Touched}=True      !cause Event:Accepted
         !If above does not truncate then must examine picture (prop:text) for max size
      ELSE
         CYCLE  !Tells RTL to do its normal thing and will try to paste?
      END
2 Likes

I can’t reproduce, I am able to paste first 20 characters of a long text into an entry(@s20).

In 11.13505 just tried pasting 99 bytes into an ENTRY(@s60) and I also see it pasted while truncating the bytes after 60. I recall seeing the problem the OP described in the past (maybe in the IDE). It does stop at the first <13,10>.

Sounds like something is triggering EVENT:Rejected. What is the data type?

Hi.
Thanky you for source code.
I have modified WindowManager.TakeWindowEvent in abwindow.clw
It works almost perfect. Cut text from clipboard is copied.
On thing is a problem.
No event accepted is called on the control when tabkey is pressed.

After CHANGE() set FOCUS(){PROP:Touched}=True

1 Like

Thank you a lot!
Now works excellent.

Regards,
Adam