Re: Giving names to undo actions
Re: Giving names to undo actions
- Subject: Re: Giving names to undo actions
- From: John Brownie <email@hidden>
- Date: Wed, 21 Dec 2016 11:22:02 +0200
OK, I think you're endorsing what I was planning. I have (among other
actions) two that are inverses of each other, add and remove. Currently
the add routine creates an action called Add, and registers the remove
routine as its undo action. The remove routine creates an action called
Remove, and register the add routine as its undo action. This leads to
the redo of add appearing as Undo Remove, and that's my problem.
So there are two approaches I can see. One is to refactor the add and
remove routines into two levels, one of which does the creation of an
undo element, and the other actually doing the work. The other is to
check whether we're undoing and not set the name in that case. At
present I'm leaning towards the latter.
John
Quincey Morris <mailto:email@hidden>
21 December 2016 at 10:44
On Dec 21, 2016, at 00:06 , John Brownie <email@hidden
<mailto:email@hidden>> wrote:
No, there are three steps: create, undo, redo. You only set the name
on the create step. So, after you do the add, the menu reads “Undo
Add”. After you undo the add, the menu reads “Redo Add”. After you
redo the add, the menu reads “Undo Add” again.
(IIRC, if you code is structured in such a way that you want to handle
multiple steps in one place, you can test the “isUndoing” and
“isRedoing” properties to decide whether to set the name.)
--
John Brownie
In Finland on furlough from SIL Papua New Guinea
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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