Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Tue Jun 19, 2018 11:02 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: question about undo functionality
PostPosted: Tue Jul 24, 2012 2:09 pm 
Offline
User avatar

Joined: Mon Jan 02, 2012 1:51 am
Posts: 382
Location: India
hi all,

By default there is a "undo" menu under the "Edit" menu. But that menu never active. But that shortcut for that menu(ctrl+z) is working.

Why there is a strange behavior like that?

I read several post on that. Looks like I have to code myself to achieve that menu functionality.

I need to implement undo only for the TextField/TextArea. What is the simplest way to do that?

Thanks.

_________________
Amitava Karan
Real Studio 2012 Release 1
Windows 7 (32 bit)
Mac OS X Version 10.7


Top
 Profile  
Reply with quote  
 Post subject: Re: question about undo functionality
PostPosted: Tue Jul 24, 2012 3:36 pm 
Offline
User avatar

Joined: Fri Sep 30, 2005 11:48 am
Posts: 3554
Location: Lenexa, KS
Undo functionality is not built-in. Find one of the available Undo subclasses for TextField/TextArea. Formatted Text Control also has built-in Undo/Redo capabilities.

_________________
Bob K.

A blog about being a Real Studio/Xojo developer at http://www.bkeeneybriefs.com


Top
 Profile  
Reply with quote  
 Post subject: Re: question about undo functionality
PostPosted: Tue Jul 24, 2012 3:43 pm 
Offline
User avatar

Joined: Mon Apr 02, 2007 2:08 am
Posts: 1225
Location: San Francisco, CA, USA
amitavak wrote:
By default there is a "undo" menu under the "Edit" menu. But that menu never active.

You will need to add a menu handler method for the Undo menuitem (use the "add menu handler" button on the code edit tab for the window in question,) in addition to implementing an actual undo-ing mechanism (there is no general-purpose Undo/Redo functionality provided.)
Quote:
But that shortcut for that menu(ctrl+z) is working.
Why there is a strange behavior like that?

The KB shortcut is only honored if you defined a menu handler. When you press Ctrl+Z in, for example, a TextField it's the Textfield that is receiving and handling the undo/redo command (this sort of text-control-specific undo is provided by the OS, I think.) It seems that once a window-level menu defines a KB shortcut, controls contained in that window will no longer receive notification of it since the window is handling them now.
[/quote]
Quote:
I read several post on that. Looks like I have to code myself to achieve that menu functionality.

I need to implement undo only for the TextField/TextArea. What is the simplest way to do that?

Here's a very basic example project implementing an undo/redo system for a TextField. This isn't the only way to do it, or even the best way, but I think it illustrates how to make one (and how easy it actually can be) well enough.

_________________
Boredom Software


Top
 Profile  
Reply with quote  
 Post subject: Re: question about undo functionality
PostPosted: Wed Jul 25, 2012 9:29 am 
Offline
User avatar

Joined: Mon Jan 02, 2012 1:51 am
Posts: 382
Location: India
Thank you charonn0,

The example you provide me a good idea how to implement undo foe TextField/TextArea. I made a demo app having a two textField and implement the undo functionality for those.

This is the link to the demo app.

But in my original application there is lots of TextField/TextArea. If I'm going to implement the same logic there, I have to code in LostFosus, GotFocus and KeyDown Events of each field. Is this a good way to do that? or there is some other way?

_________________
Amitava Karan
Real Studio 2012 Release 1
Windows 7 (32 bit)
Mac OS X Version 10.7


Top
 Profile  
Reply with quote  
 Post subject: Re: question about undo functionality
PostPosted: Wed Jul 25, 2012 11:05 am 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
make a subclass of TEXTFIELD and TEXTAREA that includes you undo/redo events

and use THOSE instead of the RB in-built ones

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: question about undo functionality
PostPosted: Wed Jul 25, 2012 1:23 pm 
Offline
User avatar

Joined: Mon Jan 02, 2012 1:51 am
Posts: 382
Location: India
Thank you dave. That approach looks more good.

_________________
Amitava Karan
Real Studio 2012 Release 1
Windows 7 (32 bit)
Mac OS X Version 10.7


Top
 Profile  
Reply with quote  
 Post subject: Re: question about undo functionality
PostPosted: Thu Jan 24, 2013 5:16 pm 
Offline

Joined: Fri Nov 16, 2012 8:10 pm
Posts: 34
amitavak wrote:
The example you provide me a good idea how to implement undo foe TextField/TextArea. I made a demo app having a two textField and implement the undo functionality for those.
This is the link to the demo app.


It works only for delete , how to make it work for cut and paste?

EDIT:

I found it
Undo.Append me.Text


must be also in MouseDown Event.

_________________
OSX 10.8.3
ListBox Example Project OSX
TextEditor Example Project OSX
Homepage


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group