NSEvent and postEvent:atStart

  • How does one create and then receive a user defined event?

    I have read and find only what appears to me to be heavyweight processes.

    So if I create an NSEvent and then use postEvent:atStart what I am not getting is how is a method  in an object associated with the NSEvent?

    Or should I just fugehabodit an use notifications?

    But, I really want to understand postEvent:atStart.

    -koko
  • On 25/05/2012, at 10:58 AM, koko wrote:

    > How does one create and then receive a user defined event?
    >
    > I have read and find only what appears to me to be heavyweight processes.
    >
    > So if I create an NSEvent and then use postEvent:atStart what I am not getting is how is a method  in an object associated with the NSEvent?
    >
    > Or should I just fugehabodit an use notifications?
    >
    > But, I really want to understand postEvent:atStart.

    It just puts the event into the queue.

    Another object will pull events off the queue. If it is looking for and understands your user event, it will process it, maybe by passing it to a specific method of an object. You can't associate a handler method of a specific object with the event in advance, so it can't just end up somewhere by magic.

    Sounds to me like notifications might be a better idea if you are just trying to communicate within the app. What are you actually trying to do?

    --Graham
  • Can you point me to the docs that cover pulling events off the queue?

    Thanks.

    -koko

    On May 24, 2012, at 7:56 PM, Graham Cox wrote:

    > Another object will pull events off the queue.
  • [NSWindow  nextEventMatchingMask:untilDate:inMode:dequeue:]

    [NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:]

    On 25/05/2012, at 12:40 PM, koko wrote:

    > Can you point me to the docs that cover pulling events off the queue?
    >
    > Thanks.
    >
    > -koko
    >
    > On May 24, 2012, at 7:56 PM, Graham Cox wrote:
    >
    >> Another object will pull events off the queue.
    >
  • On May 24, 2012, at 11:53 PM, Graham Cox wrote:

    > On 25/05/2012, at 12:40 PM, koko wrote:
    >
    >> On May 24, 2012, at 7:56 PM, Graham Cox wrote:
    >>
    >>> Another object will pull events off the queue.
    >>
    >> Can you point me to the docs that cover pulling events off the queue?
    >
    > [NSWindow  nextEventMatchingMask:untilDate:inMode:dequeue:]
    >
    > [NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:]

    Those are correct, but most events are pulled from the queue (using those methods) inside of Cocoa and then delivered to the application object via the -sendEvent: method.  An override of that is often where one would see their own application-specific events.

    Regards,
    Ken
  • Thanks a bunch!

    Overriding -sendEvent seems easiest.

    -koko

    On May 25, 2012, at 7:04 AM, Ken Thomases wrote:

    > On May 24, 2012, at 11:53 PM, Graham Cox wrote:
    >
    >> On 25/05/2012, at 12:40 PM, koko wrote:
    >>
    >>> On May 24, 2012, at 7:56 PM, Graham Cox wrote:
    >>>
    >>>> Another object will pull events off the queue.
    >>>
    >>> Can you point me to the docs that cover pulling events off the queue?
    >>
    >> [NSWindow  nextEventMatchingMask:untilDate:inMode:dequeue:]
    >>
    >> [NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:]
    >
    > Those are correct, but most events are pulled from the queue (using those methods) inside of Cocoa and then delivered to the application object via the -sendEvent: method.  An override of that is often where one would see their own application-specific events.
    >
    > Regards,
    > Ken
    >
    >
previous month may 2012 next month
MTWTFSS
  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      
Go to today