Annotation of Examples/AppKit/Draw/graphicsUndo.subproj/EndEditingGraphicsChange.m, revision 1.1

1.1     ! root        1: #import "drawundo.h"
        !             2: 
        !             3: /*
        !             4:  * This change is created when the user finishes editing a text
        !             5:  * graphic. Undoing this change inserts the re-inserts the text
        !             6:  * editing cursor in the text. More significantly, undoing this
        !             7:  * change swaps the contents of the TextGraphic back into the
        !             8:  * field editor so that it is ready to edit.
        !             9:  */
        !            10: 
        !            11: @interface EndEditingGraphicsChange(PrivateMethods)
        !            12: 
        !            13: @end
        !            14: 
        !            15: @implementation EndEditingGraphicsChange
        !            16: 
        !            17: - initGraphicView:aGraphicView graphic:aGraphic
        !            18: {
        !            19:     [super init];
        !            20:     graphicView = aGraphicView;
        !            21:     graphic = aGraphic;
        !            22: 
        !            23:     return self;
        !            24: }
        !            25: 
        !            26: - free
        !            27: {
        !            28:     if ([self hasBeenDone] && [graphic isEmpty])
        !            29:         [graphic free];
        !            30:     return [super free];
        !            31: }
        !            32: 
        !            33: - (const char *)changeName
        !            34: {
        !            35:     return NXLocalStringFromTable("Operations", "End Editing", NULL, "The operation of ending the editing process and proceding onto some other operation.");
        !            36: }
        !            37: 
        !            38: - undoChange
        !            39: {
        !            40:     if ([graphic isEmpty])
        !            41:        [graphicView insertGraphic:graphic];
        !            42:     [graphic prepareFieldEditor];    
        !            43:     [NXApp startEditMode];
        !            44:     return [super undoChange];
        !            45: }
        !            46: 
        !            47: - redoChange
        !            48: {
        !            49: /* 
        !            50:  * The order of the next two statements is important.
        !            51:  * If endEditMode were sent before resignFieldEditor 
        !            52:  * it would send resetCursor to the document which would
        !            53:  * make the window the first responder which would end
        !            54:  * up sending textDidEnd:endChar: to the TextGraphic.
        !            55:  * Then in the next line we'd send resignFieldEditor to
        !            56:  * the TextGraphic even though it had already resigned 
        !            57:  * the field editor.
        !            58:  */
        !            59:     [graphic resignFieldEditor];
        !            60:     [NXApp endEditMode];
        !            61:     if ([graphic isEmpty])
        !            62:        [graphicView removeGraphic:graphic];
        !            63:     return [super redoChange];
        !            64: }
        !            65: 
        !            66: @end

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.