Re: Custom NSView and NSUndoManager SOLVED
Re: Custom NSView and NSUndoManager SOLVED
- Subject: Re: Custom NSView and NSUndoManager SOLVED
- From: Benjamin Dunton <email@hidden>
- Date: Thu, 10 Nov 2005 18:37:26 -0500
I figured out my problem. Just incase someone else comes along who
does not quite understand the NSResponder, a brief explanation:
The NSResponder handles events and actions for objects, normally the
window or views. In the case of NSUndoManager, whenever anything is
added to the undo stack the responder chain is traversed looking for
the first responder that can handle the undo: action.
My problem was this, my undoable views were subviews of a container.
If a mouseDown: was received on the view, it was passed up to the
container so that all views could be handeled appropriately (think
collision detection). Therefore, the undo actions were getting added
to the stack; however, since the subviews were outside of the
starting point of the responder chain (one level above the subviews
in the container view), I had to click on the container in order to
execute the undo/redo functionality. This was solved by making the
subview that received the mouseDown: the first responder after the
mouseDown: event was handeled by the superview (container).
Works like a charm! Thanks Jim!
Ben
On Nov 10, 2005, at 7:31 AM, Jim Correia wrote:
On Nov 10, 2005, at 5:58 AM, Benjamin Dunton wrote:
I was thinking about this some more this morning, and with what
you are saying, tell me if this makes since. I have a text view
in the application as well, and after calling [self setAllowsUndo]
in the awakeFromNib:, undo/redo works. I am thinking that if I
get the undo manager from the text views delegate (which also
happens to be my window controller), that things might start working?
Does your window controller own its own undo manager?
If your window doesn't, it probably should at this point, and you
should make yourself the window's delegate and return it from
- (NSUndoManager *)windowWillReturnUndoManager:(NSWindow *)window;
Jim
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden