• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Using Undo for a ported PC app
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using Undo for a ported PC app


  • Subject: Re: Using Undo for a ported PC app
  • From: Robb Albright <email@hidden>
  • Date: Wed, 24 Jan 2007 12:05:15 -0800


On Jan 24, 2007, at 7:07 AM, "Theodore H. Smith" <email@hidden> wrote:


Hi people,

I've been porting a PC app to the Mac.

This app doesn't use any undo framework. It uses a two state system,
where the entire current document is copied over to another backup
state, before any change is made. Then the change is made, and an
undo is made available. It's all done with C++ objects, no NS objects
going on for the undo.

Now, how should I integrate that with NSUndoManager?

I've actually just come across the same issue with my cross-platform app. It does undo the same way.

The important method that I found I needed to deal with was the - (NSUndoManager*)windowWillReturnUndoManager:(NSWindow*)sender
delegate message for the window.


I left the regular undo: redo: actions on the menus (this lets them work in NSTextFields too), and then return an instance of my own NSUndoManager subclass (which only implements the methods needed by the menu system. However, this did make automatic undo handling for text views not work in the main window. So, I have to return a regular NSUndoManager instance if that's the case (if you don't implement this, NSWindow creates an undo manager for use by text views).

Here's my solution in pseudocode:

-(NSUndoManager*)windowWillReturnUndoManager:(NSWindow*)sender
{
	if ( currentTargetIsTextView )
		return instance of NSUndoManager
	else
		return instance of MyUndoManager
}

Then, the NSUndoManager subclass (MyUndoManager) implements:

-(BOOL)canUndo
-(BOOL)canRedo

-(NSString*)undoMenuItemTitle
-(NSString*)redoMenuItemTitle

-(void)undo
-(void)redo

and in all cases, calls thru to the xplat app object to get this info (and coerces returns to cocoa types)



<snip>
--


http://elfdata.com/plugin/



Hope this helps,

robb albright
vernier software & technology
email@hidden


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: Using Undo for a ported PC app
  • Next by Date: Re: Lucene/Cocoa integration
  • Previous by thread: Re: Using Undo for a ported PC app
  • Next by thread: Lucene/Cocoa integration
  • Index(es):
    • Date
    • Thread