Professional Web Applications Themes

more os x event stuff - Mac Programming

I would like the close box on a window to hide it, but not destroy it, so I can easily show it again later without recreating it. I installed an event handler on the window like so: InstallStandardEventHandler(GetWindowEventTarget(g ColorsWindow)); EventTypeSpec eventTypeWD = {kEventClassWindow, kEventWindowClose}; InstallWindowEventHandler (gColorsWindow, NewEventHandlerUPP(DoWindowHide), 1, &eventTypeWD, NULL, NULL); with the handler written: pascal OSStatus DoWindowHide(EventHandlerCallRef nextHandler, EventRef theEvent, void* userData) { WindowRef window; OSStatus result = eventNotHandledErr; GetEventParameter(theEvent, kEventParamDirectObject, typeWindowRef, NULL, sizeof(window), NULL, &window); HideWindow(window); //result = CallNextEventHandler (nextHandler, theEvent); return result; } I've tried it with the CallNextEventHandler call uncommented as well. Neither works. The window ...

  1. #1

    Default more os x event stuff

    I would like the close box on a window to hide it, but not destroy it, so
    I can easily show it again later without recreating it.

    I installed an event handler on the window like so:

    InstallStandardEventHandler(GetWindowEventTarget(g ColorsWindow));
    EventTypeSpec eventTypeWD = {kEventClassWindow, kEventWindowClose};
    InstallWindowEventHandler (gColorsWindow,
    NewEventHandlerUPP(DoWindowHide), 1, &eventTypeWD, NULL, NULL);

    with the handler written:

    pascal OSStatus DoWindowHide(EventHandlerCallRef nextHandler,
    EventRef theEvent, void* userData)
    {
    WindowRef window;
    OSStatus result = eventNotHandledErr;

    GetEventParameter(theEvent, kEventParamDirectObject,
    typeWindowRef, NULL, sizeof(window),
    NULL, &window);
    HideWindow(window);

    //result = CallNextEventHandler (nextHandler, theEvent);

    return result;
    }

    I've tried it with the CallNextEventHandler call uncommented as well.
    Neither works. The window is closed, not hidden. I thought installing my
    own handler would override the system handling of the event. What am I
    doing wrong? Thanks.

    __________________________________________________ ______________________
    Keith Wiley unm.edu
    http://www.unm.edu/~keithw http://www.mp3.com/KeithWiley

    "Yet mark his perfect self-contentment, and hence learn his lesson,
    that to be self-contented is to be vile and ignorant, and that to
    aspire is better than to be blindly and impotently happy."
    -- Edwin A. Abbott, Flatland
    __________________________________________________ ______________________
    Keith Guest

  2. #2

    Default Re: more os x event stuff

    On Wed, 19 Nov 2003, Keith Wiley wrote:
     
    You are returning eventNotHandledErr. This tells the system that the
    event has not been dealt with, so it should propagate it further down the
    chain of event handlers.

    To achieve what you want to do, you should instead return noErr.

    Fred

    Frederick Guest

  3. #3

    Default Re: more os x event stuff

    On Wed, 19 Nov 2003, Frederick Cheung wrote:
     

    That did it. Thanks. Should I be handing it off CallNextEventHandler
    after I'm through with it, or if I know I did what I want to do should I
    not call CallNextEventHandler?

    __________________________________________________ ______________________
    Keith Wiley unm.edu
    http://www.unm.edu/~keithw http://www.mp3.com/KeithWiley

    "Yet mark his perfect self-contentment, and hence learn his lesson,
    that to be self-contented is to be vile and ignorant, and that to
    aspire is better than to be blindly and impotently happy."
    -- Edwin A. Abbott, Flatland
    __________________________________________________ ______________________
    Keith Guest

  4. #4

    Default Re: more os x event stuff

    On Wed, 19 Nov 2003, Keith Wiley wrote:
     
    >
    > That did it. Thanks. Should I be handing it off CallNextEventHandler
    > after I'm through with it, or if I know I did what I want to do should I
    > not call CallNextEventHandler?
    >[/ref]
    CallNextHandler does exactly the same thing in terms of propagation as
    returning noErr, the only difference being that you handler gets control
    back once the handlers below it have completed there processing. In your
    case this is not what you want to do, in general explicit propagation is
    only really needed when you want the window/control/whatever to perform
    its usual processing before adding on some bells and whistles yourself.

    Fred

    Frederick Guest

Similar Threads

  1. Getting Error: Event Type 'flash.event:event' is unavailable ?????
    By malik.robinson@gmail.com in forum Macromedia Flex General Discussion
    Replies: 0
    Last Post: January 14th, 01:51 AM
  2. stumped...table - row - click event, cancel checkbox event
    By dave in forum ASP.NET Building Controls
    Replies: 0
    Last Post: September 2nd, 01:28 AM
  3. Replies: 2
    Last Post: December 17th, 03:58 PM
  4. Replies: 0
    Last Post: April 5th, 02:26 PM
  5. Replies: 0
    Last Post: July 28th, 11:40 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139