nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(aKeyEvent)); if (privateEvent) { nsEvent *theEvent; privateEvent->GetInternalNSEvent(&theEvent); const nsGUIEvent *guiEvent = (nsGUIEvent*)theEvent; const EventRecord *ev = (EventRecord*)(guiEvent->nativeMsg); if (guiEvent && guiEvent->message == NS_KEY_PRESS && ev && ev->what == keyDown) return NS_OK; }
nsresult nsPluginInstanceOwner::KeyPress(nsIDOMEvent* aKeyEvent){#if defined(XP_MAC) || defined(XP_MACOSX) // send KeyPress events only on Mac  // Nasty hack to avoid recursive event dispatching with Java. Java can  // dispatch key events to a TSM handler, which comes back and calls   // [ChildView insertText:] on the cocoa widget, which sends a key  // event back down.  static PRBool sInKeyDispatch = PR_FALSE;    if (sInKeyDispatch)    return NS_ERROR_FAILURE; // means consume event  sInKeyDispatch = PR_TRUE;  nsresult rv =  DispatchKeyToPlugin(aKeyEvent);  sInKeyDispatch = PR_FALSE;  return rv;#else  if (mInstance) {    // If this event is going to the plugin, we want to kill it.    // Not actually sending keypress to the plugin, since we didn't before.    aKeyEvent->PreventDefault();    nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aKeyEvent));    if (nsevent) {      nsevent->PreventBubble();    }    return NS_ERROR_FAILURE; // means consume event                               }  return NS_OK;#endif}