NPAPI:AdvancedKeyHandling: Difference between revisions

Line 32: Line 32:
'''NPAPI Advanced Key Handling (AKH) Support'''
'''NPAPI Advanced Key Handling (AKH) Support'''


* Last modified: March 17, 2009
* Last modified: March 18, 2009
* Author: Josh Aas, Mozilla Corporation
* Author: Josh Aas, Mozilla Corporation
* Contributors: Johnny Stenback (Mozilla), Aaron Leventhal (IBM), Oliver Yeoh (Sun), Danielle Pham (Sun), Deneb Mateka (Adobe), Anders Carlsson (Apple)
* Contributors: Johnny Stenback (Mozilla), Aaron Leventhal (IBM), Oliver Yeoh (Sun), Danielle Pham (Sun), Deneb Mateka (Adobe), Anders Carlsson (Apple)
Line 50: Line 50:
//  The browser is then able to take further action if that is necessary for some reason.
//  The browser is then able to take further action if that is necessary for some reason.
// Return value indicates whether or not the browser handled the event.
// Return value indicates whether or not the browser handled the event.
NPBool NPN_HandleEvent(NPP instance, NPEvent *event, NPBool handled);
NPBool NPN_HandleEvent(NPP instance, void *event, NPBool handled);
</pre>
</pre>


Line 67: Line 67:
// Direction argument indicates whether the next or the previous element should take focus.
// Direction argument indicates whether the next or the previous element should take focus.
// Return value indicates whether or not the browser will take focus.
// Return value indicates whether or not the browser will take focus.
NPBool NPN_GiveUpFocus(NPP instance, NPFocusDirection direction);
NPBool NPN_UnfocusInstance(NPP instance, NPFocusDirection direction);


// Called by the browser when the browser intends to take focus.
// Called by the browser when the browser intends to take focus.
Line 73: Line 73:
// Direction argument indicates the direction of the element receiving focus.
// Direction argument indicates the direction of the element receiving focus.
// There is no return value, plugins will lose focus when this is called.
// There is no return value, plugins will lose focus when this is called.
NPBool NPP_LostFocus(NPP instance, NPFocusDirection direction);
void NPP_LostFocus(NPP instance, NPFocusDirection direction);


// Called by the browser when the browser intends to focus an instance.
// Called by the browser when the browser intends to focus an instance.
Line 84: Line 84:
When a plugin takes focus, it will receive an <tt>NPP_GotFocus</tt> call before receiving any events that might have given it focus, such as a mouse click. The plugin may not receive the event that gave it focus if the browser considers itself to have handled the event by giving focus to the plugin. For example, the browser may handle a tab key press by giving focus to the plugin and having handled the event, not send the tab key to the plugin.
When a plugin takes focus, it will receive an <tt>NPP_GotFocus</tt> call before receiving any events that might have given it focus, such as a mouse click. The plugin may not receive the event that gave it focus if the browser considers itself to have handled the event by giving focus to the plugin. For example, the browser may handle a tab key press by giving focus to the plugin and having handled the event, not send the tab key to the plugin.


If a plugin receives an event that causes it to attempt to give up focus, the plugin should simply call NPN_GiveUpFocus and not pass on the event since attempting to give up focus is essentially handling the event.
If a plugin receives an event that causes it to attempt to give up focus, the plugin should simply call NPN_UnfocusInstance and not pass on the event since attempting to give up focus is essentially handling the event.


Focus events will not be passed to plugins via <tt>NPP_HandleEvent</tt> when AKH is enabled. Per platform, this means:
Focus events will not be passed to plugins via <tt>NPP_HandleEvent</tt> when AKH is enabled. Per platform, this means:
Confirmed users, Bureaucrats and Sysops emeriti
1,680

edits