WebView keyboard events

  • Hi list,
    I need to intercept keys inside a WebView.
    I can read:

    -----
    "Subclassing the WebView won't work, because this key binding is
    handled by another view inside the WebView.

    The easiest way get the event before the view inside the WebView does
    is to subclass NSWindow and override sendEvent: or subclass
    NSApplication and override sendEvent:."
    ------

    Ok I've subclassed my NSWindow:

    - (void)keyDown:(NSEvent *)theEvent { NSLog(@"click"); }
    - (BOOL) becomeFirstResponder { return YES; }

    - (void)flagsChanged:(NSEvent *)theEvent { }
    - (void)keyUp:(NSEvent *)theEvent { }

    - (BOOL)acceptsFirstResponder { return YES; }
    - (BOOL)resignFirstResponder { return YES; }

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

    now the problem appears when the user click on an object and my
    NSWindow stops to receive the keyDown events (->
    resignFirstResponder). Now if I try to return NO in
    resignFirstResponder I cannot use my interface.
    How can I continue to receive events about keys pressed? Is there a
    way? (In fact I need to use them only when an NSTabView show a
    particular tabviewitem).
    Thanks a lot
    malcom
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