• 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
Out-of-order Undos and NSTextField
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Out-of-order Undos and NSTextField


  • Subject: Out-of-order Undos and NSTextField
  • From: James Bucanek <email@hidden>
  • Date: Sat, 8 Jul 2006 09:48:24 -0700

I've got a bizarre problem, and I'm not sure what's going on or how to attack the problem.

I have a window with three controls (well, there are actually a lot more but the three is all you need).

    - NSTextField, with a number formatter, bound to an int property in my controller
    - NSPopUpButton A, bound to an int property in my controller
    - NSPopUpButton B, bound to an int property in my controller

In all of the property setters (setFromOffset:(int), setFromScale:(int)...) I register a copy of the previous value with the undo manager before updating the value in the data model. Like this:

// General purpose undo register for all actions that change the value of the merge picker
- (void)registerUndoMergePicker
{
    NSUndoManager* undoManager = [document undoManager];
    [undoManager registerUndoWithTarget:self
                               selector:@selector(undoMergePicker:)
                                 object:[[[self activeMergePicker] copy] autorelease]];
    [undoManager setActionName:@"Change Merge Criteria"];
}

// Proxy property that is bound to UI. Changes are propogated to active merge picker.
- (int)mergeFromOffset
{
    return ([[self activeMergePicker] fromOffset]);     // if activeMergePicker==nil, returns 0
}

- (void)setMergeFromOffset:(int)offset
{
    LayerRelativePicker* picker = [self activeMergePicker];
    if (picker!=nil && [picker fromOffset]!=offset)
        {
        [self registerUndoMergePicker];
        [picker setFromOffset:offset];
        }
}

The same pattern is repeated on all of the other bound properties of my controller. But here's what happens in the interface...

---- me -----                       ----- UI -----

(initial state: text field contains the text "1" and the both pop-up buttons are set to their first value, 1 and 1)

Edit text field, changing "1" to "12"

                                    Undo menu says "Undo Typing"

Change pop-up A to 2

                                    Undo menu still says "Undo Typing"

Change pop-up B to 3

                                    Undo menu still says "Undo Typing"

Edit > Undo

                                    Edit fields changes back to "1" (!!!)
                                    Undo menu says "Undo Merge Critera Change"

Edit > Undo

                                    Pop-up B changes back to 1
                                    Undo menu says "Undo Merge Critera Change"

Edit > Undo

                                    Pop-up A changes back to 1
                                    Undo menu disabled

How do I get these to operate in the correct order? Do I have multiple Undo managers at work here? How can I coordinate them or use just one?
--
James Bucanek
 _______________________________________________
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

  • Follow-Ups:
    • Re: Out-of-order Undos and NSTextField
      • From: James Bucanek <email@hidden>
  • Prev by Date: Re: [newbie]How to pop a window?
  • Next by Date: Re: Objective-C and it's future
  • Previous by thread: Stealing keyboard focus without activating
  • Next by thread: Re: Out-of-order Undos and NSTextField
  • Index(es):
    • Date
    • Thread