Jump to content
FabDev

Make a TMemo.seltext modification cancellable by the user

Recommended Posts

Posted (edited)

Hello,

 

On a basic TMemo (or any TEdit) Undo work by default when the end user modify something.

Problem if you change something by code like a simple :
 

Memo1.Seltext:='Bob';

 

After this Undo (CTRL + Z ) will not work for the user. If he want to cancel my "Bob".

So how to force a modification by code to be in Undo stack ?

 

 

 

Edited by FabDev

Share this post


Link to post
Posted (edited)

I did not know this CanUndoSelText method, but It's exactly that I need.

Thank you very much !

 

Edited by FabDev

Share this post


Link to post
5 hours ago, Lajos Juhász said:

It was introduced recently. Delphi XE5 does not have it yet.

It was added in 11.0 Alexandria.

http://docwiki.embarcadero.com/RADStudio/Alexandria/en/What's_New#Smaller_Changes

Quote

Smaller Changes

  • SetSelText and SetSelTextBuf offer the option not to reset the Undo buffer.
  • This is managed by a new property CanUndoSelText. It is False by default, which maintains backwards compatibility. If set to True it allows Undo to be called (or an Undo operation to be invoked with the UI) to undo a change made with calls to SetSelText or SetSelTextBuf or by assignments to the SelText property.

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×