Create a constantly updated user control with the right cancel control

I compile a custom NSView that processes two values ​​through bindings. I am distributing the values ​​in the updates described by Tom Dallin in the question Can you manually implement Cocoa bindings? . It all works great.

In order to constantly update the management, I update and distribute the values ​​in the method -mouseDragged. Again, this works fine, but it logs intermediate steps for NSUndoManager, which I don't want. So, I tried to release disableUndoRegistrationin -mouseDown, and then enableUndoRegistrationin mouseUp. Naturally, I update the results again and again.

No cancellation was registered, and I realized this because my set function does not register cancellation if the value does not change:

- (void)setX:(double)newX {
    if (newX != x) {
        [[undoManager prepareWithInvocationTarget:self] setX:x];
        [self willChangeValueForKey:@"x"];
        x = newX;
        [self didChangeValueForKey:@"x"];
    }
}

Since the -mouseDraggedvalue had already spread, it did not change when it was sent back to -mouseUp, so the cancellation was never recorded. Of course, I want him to cancel this place to the initial one -mouseDown, so let me say that I do this by storing this value in the control and then sending it again to -mouseUpbefore I send the new value. It, of course, still has a problem that I see a flash of it, returning to its old meaning.

-setX:, , . , , (, NSSlider ).

!

+3
1

beginUndoGrouping endUndoGrouping?


P.S. , Cocoa, GNUstep (NSUndoManager GNUstep Base, AppKit, NSSliderCell, GNUstep GUI):

http://wwwmain.gnustep.org/resources/downloads.php?site=http%3A%2F%2Fftpmain.gnustep.org%2Fpub%2Fgnustep%2F#core

+2

All Articles