handling events within NSWindow

  • I am giving up trying to customize WebView and instead trying to
    handle events in the NSWindow that contains my WebView.

    I have created a subclass of the NSWindow containing my WebView and
    added:

    - (void) sendEvent: (NSEvent *) theEvent
    {
        NSLog(@"%@", theEvent);
        [super sendEvent: theEvent];
    }

    My application compiles fine and displays the web request. But
    keypresses (among other events) are not NSLog'ed in the run log.

    Are there any outlets I need to wire with my NSWindow+customclass to
    handle events?

    I have been reading this:

    http://developer.apple.com/documentation/Cocoa/Reference/
    ApplicationKit/Classes/NSWindow_Class/Reference/Reference.html#//
    apple_ref/occ/instm/NSWindow/sendEvent:

    and it says never to invoke this directly. But I don't know where
    else to put this since I want to simply debug where events are going
    within my WebView (let alone do anything with this).

    Regards,
    Alex
  • On 14 Oct 2006, at 2:36 PM, Alex Reynolds wrote:

    > I am giving up trying to customize WebView and instead trying to
    > handle events in the NSWindow that contains my WebView.
    >
    > I have created a subclass of the NSWindow containing my WebView and
    > added:
    >
    > - (void) sendEvent: (NSEvent *) theEvent
    > {
    > NSLog(@"%@", theEvent);
    > [super sendEvent: theEvent];
    > }
    >
    > My application compiles fine and displays the web request. But
    > keypresses (among other events) are not NSLog'ed in the run log.
    >
    > Are there any outlets I need to wire with my NSWindow+customclass
    > to handle events?

    The events of interest might be sent to the application's responder
    chain. In that case, it would be NSApplication's sendAction:to:from:
    that would be of interest.

    To prevent a whole lot of extraneous events, your subclass could
    intercept what the responder chain calls and log that. See http://
    cocoadev.com/index.pl?NSResponder.
previous month october 2006 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