NPEvent

« Gecko Plugin API Reference « Plug-in Side Plug-in API

Summary

Represents an event passed by NPP_HandleEvent() to a windowless plug-in.

Syntax

Microsoft Windows
typedef struct _NPEvent
{
    uint16 event;
    uint32 wParam;
    uint32 lParam;
} NPEvent;
Mac OS
typedef EventRecord NPEvent;
TYPE EventRecord =
    RECORD {
       what:      Integer;
       message:   LongInt;
       when:      LongInt;
       where:     Point;
       modifiers: Integer;
    END;
XWindows
typedef XEvent NPEvent;

Fields

NPEvent on Microsoft Windows

The data structure has the following fields:

event
One of the following event types:
  • WM_PAINT
  • WM_LBUTTONDOWN
  • WM_LBUTTONUP
  • WM_LBUTTONDBLCLK
  • WM_RBUTTONDOWN
  • WM_RBUTTONUP
  • WM_RBUTTONDBLCLK
  • WM_MBUTTONDOWN
  • WM_MBUTTONUP
  • WM_MBUTTONDBLCLK
  • WM_MOUSEMOVE
  • WM_KEYUP
  • WM_KEYDOWN
  • WM_SETCURSOR
  • WM_SETFOCUS
  • WM_KILLFOCUS
For information about these events, see the Microsoft Windows developer documentation.
wParam
32 bit field for the Windows event parameter; parameter value depends upon event type.
lParam
32 bit field for the Windows event parameter; parameter value depends upon event type.
EventRecord NPEvent on Mac OS

NPEvent is defined as an EventRecord data structure, which has the following fields:

what
Integer representing an event type. Both windowed and windowless plug-ins receive the same events.
Values:
  • 0 nullEvent
  • 1 mouseDown
  • 2 mouseUp
  • 3 keyDown
  • 4 keyUp
  • 5 autoKey
  • 6 updateEvt
  • 7 diskEvt
  • 8 activateEvt
  • 15 osEvt
  • 23 kHighLevelEvent
getFocusEvent
0, 1 (true, false)
loseFocusEvent
adjustCursorEvent 0, 1 (true, false)
For information about these events, see the Mac OS developer documentation.
message
LongInt. Additional information about the event. Type of information depends on the event type. Undefined for null, mouseUp, and mouseDown events.
when
LongInt. Ticks since start-up.
where
Point. Cursor location.
modifiers
Integer. Flags.
XEvent NPEvent on Unix/X11

NPEvent is defined as an XEvent data structure, which is a union of a number of different X11 event structures.

type
The type member is an int representing an event type, and indicating which structure is relevant. The event type may be any of the ollowing:
  • GraphicsExpose
  • FocusIn
  • FocusOut
  • EnterNotify
  • LeaveNotify
  • MotionNotify
  • ButtonPress
  • ButtonRelease
  • KeyPress
  • KeyRelease

Description

Microsoft Windows Description

The type NPEvent represents an event passed by NPP_HandleEvent() to a windowless plug-in. For information about these events, see your Microsoft Windows documentation.

Mac OS Description

The NPEvent object represents an event passed by NPP_HandleEvent() to a windowless plug-in. This structure is defined as EventRecord, the event type used by Mac OS. On Mac OS, plug-ins receive the same events for both windowed and windowless plug-ins, as follows.

  • Mouse events: Sent if the mouse is within the bounds of the instance.
  • Key events: Sent if the instance has text focus (see below).
  • Update events: Sent if the update region intersects the instance's bounds.
  • Activate events: Sent to all instances in the window being activate or deactivated.
  • Suspend/Resume events: Sent to all instances in all windows.
  • Null events: Sent to all instances in all windows.

In addition to these standard types, the browser provides three additional event types that can be passed in the what field of the EventRecord:

  • getFocusEvent: Sent when the instance could become the focus of subsequent key events, when the user clicks the instance or presses the tab key to focus the instance.
  • If your instance accepts key events, return true, and key events will be sent to the instance until it receives a loseFocusEvent.
  • If your plug-in ignores key events, return false, and the key events will be processed by the browser itself.
  • loseFocusEvent: Sent when the instance has lost the text focus, as a result of the user clicking elsewhere on the page or pressing the Tab key to move the focus. No key events are sent to the instance until the next getFocusEvent.
  • adjustCursorEvent: Sent when the mouse enters or leaves the bounds of the instance.
  • If your plug-in wants to set the cursor when the mouse is within the instance, set the cursor and return true.
  • If you don't want a special cursor, return false and the browser will use the standard arrow cursor.
XWindows Description

The NPEvent object represents an event passed by NPP_HandleEvent() to a windowless plug-in. The NPEvent structure is defined as XEvent, the definition of the event type used by the XWindows platform. For information about the XEvent structure and XWindows events, see the XWindows documentation.

As the XEvents sent to the plug-in are synthesized and there is not a native window corresponding to the plug-in rectangle, some of the members of the XEvent structures are not set to their normal Xserver values. e.g. Key events don't have a position.

Mouse events have x and y coordinates relative to the top-left corner of the plugin rectangle.

See Also

NPP_HandleEvent()

Document Tags and Contributors

Tags: 
 Contributors to this page: teoli, Karlt, Sheppy, Pmash
 Last updated by: teoli,