FROM : James Bucanek
DATE : Sat Jul 08 18:48:24 2006
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
DATE : Sat Jul 08 18:48:24 2006
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
| Related mails | Author | Date |
|---|---|---|
| James Bucanek | Jul 8, 18:48 | |
| James Bucanek | Jul 10, 01:32 | |
| Ken Victor | Jul 10, 19:08 | |
| Bill Cheeseman | Jul 10, 19:57 | |
| Ken Victor | Jul 10, 21:29 | |
| Bill Cheeseman | Jul 10, 21:53 | |
| James Bucanek | Jul 10, 22:58 | |
| James Bucanek | Jul 11, 21:05 | |
| Ken Victor | Jul 11, 21:37 | |
| James Bucanek | Jul 12, 00:04 |






Cocoa mail archive

