[Home] [ToC] [Up] [Prev] [Next]
The browser's event services provide an abstract interface to user interface events that occur within the browser. This includes typical graphical user interface events such as keyboard and mouse movement, as well as higher-level browser events such as printing, changes in the view of a document, and selection of hyperlinks.
These services are typically implemented in two pieces, with the user interface events being implemented by the operating system glue and the document events a part of the browser glue.
typedef enum { ATTRTYPE_NONE_ID, /* No attribute value returned */ ATTRTYPE_INTEGER_ID, /* Returned attribute is an integer */ ATTRTYPE_STRING_ID, /* Attribute points to 0-term string */ _ATTRTYPE_NUM } IHAttrType;
This enumeration is used to indicated the actual type of an attribute that is returned by the browser or being sent to it.
typedef void* IHAttrVal; /* Type to use for attributes */
This type is used to hold an arbitrary attribute value. When getting and setting attributes, it is used in conjunction with IHAttrType to manipulute attributes of arbitrary type.
struct ih_event_rec { IHGlobalInfo* interface; /* Interface event is for */ IHLangEnv* langenv; /* Language to send to / owns object */ IHDocument document; /* The document event is associated with */ IHEventClass class; /* Major event class */ IHEventCode code; /* Minor event type */ void* object; /* Object associated with event. The type this points to depends on the event class. */ /* The browser may append private information after this structure */ };
This event type represents a single action that can occur in the iHTML system. This includes standard user interface events such as button and keyboard presses, as well as higher-level events such as a document being printed or a hyperlink being displayed.
Each event is associated with a particular document, which tells where in the browser component it is located, and a language environment that associates it with a particular scripting language running in that document. In addition, its major class identifier describes the high-level type of the event, with the minor code identifying the exact action that occured.
typedef enum { IEATTR_CUSTOM_ID = -1, /* Attribute custom to program */ IEATTR_VIEW_TOP_ID = 0, /* Top pixel of container view */ IEATTR_VIEW_BOTTOM_ID, /* Bottom pixel of container view */ IEATTR_VIEW_LEFT_ID, /* Left pixel of container view */ IEATTR_VIEW_RIGHT_ID, /* Right pixel of container view */ IEATTR_VIEW_WIDTH_ID, /* Pixel width of container view */ IEATTR_VIEW_HEIGHT_ID, /* Pixel height of container view */ IEATTR_VIEW_FULLWIDTH_ID, /* Pixel width of container object */ IEATTR_VIEW_FULLHEIGHT_ID, /* Pixel height of container object */ IEATTR_ANCHOR_NAME_ID, /* The href of anchor that caused event */ IEATTR_MOUSE_X_ID, /* Current mouse x position */ IEATTR_MOUSE_Y_ID, /* Current mouse y position */ IEATTR_MOUSE_BUTTON_ID, /* Mouse button which was pressed/released */ IEATTR_MOUSE_STATE_ID, /* Current mouse button flags, see below */ IEATTR_KEY_ASCII_ID, /* ASCII value of keypress */ IEATTR_KEY_STATE_ID, /* Current key qualifier flags, see below */ IEATTR_REDRAW_X_ID, /* Region that needs to be redrawn */ IEATTR_REDRAW_Y_ID, IEATTR_REDRAW_WIDTH_ID, IEATTR_REDRAW_HEIGHT_ID, _IEATTR_NUM } IHEventAttr;
This type identifies the basic attributes that can be assigned and retrieved from an event. Their availability and interpretation depends on the event class and code, as follows:
The following bits are defined for the IEATTR_MOUSE_STATE_ID and IEATTR_BUTTON_ID attributes:
#define IEMOUSE_SELECT_ID (1<<0) /* Select button */ #define IEMOUSE_POPUP_ID (1<<1) /* Popup menu button */ #define IEMOUSE_OPTION_ID (1<<2) /* Optional action (ie, draw w/background) */
The following bits are defined for the IEATTR_KEY_STATE_ID attribute:
#define IEKEY_SHIFT_ID (1<<0) /* Shift key is down */ #define IEKEY_CONTROL_ID (1<<1) /* Control key is down */ #define IEKEY_CAPS_ID (1<<2) /* Caps-lock key is down */ #define IEKEY_ALT_ID (1<<3) /* Alt inducer key is down */
typedef enum { IECLASS_CUSTOM_ID = -1, /* A event class custom to program */ IECLASS_NULL_ID = 0, /* A nothing event */ IECLASS_DOCUMENT_ID, /* An event for the entire document */ IECLASS_WIDGET_ID, /* A widget-specific event */ _IECLASS_NUM /* Number of possible events classes */ } IHEventClass;
This type enumerates the possible classes of events, which determine the general structure and attributes of the event. It also determines that type the IHEvent's object field is, as follows:
typedef enum { IECODE_CUSTOM_ID = -1, /* A event code custom to program */ IECODE_ANY_ID = 0, /* Any event type */ IECODE_DISPLAYED_ID, /* A view has been displayed. */ IECODE_LOADED_ID, /* A data requested has finished loading. */ IECODE_SCROLL_ID, /* Scroll within container */ IECODE_ONANCHOR_ID, /* Mouse pointer has moved on hypertext link. */ IECODE_OFFANCHOR_ID, /* Mouse pointer has moved off hypertext link. */ IECODE_HITANCHOR_ID, /* User has selected a hypertext link. */ IECODE_PRINT_ID, /* Being printed. Not implemented for widgets. */ IECODE_RESIZE_ID, /* Resize object */ IECODE_REDRAW_ID, /* Object needs to redraw itself */ IECODE_MOUSEMOVE_ID, /* Mouse has moved */ IECODE_MOUSEPRESS_ID, /* Mouse button pressed */ IECODE_MOUSERELEASE_ID, /* Mouse button released */ IECODE_KEYPRESS_ID, /* Keyboard button pressed */ IECODE_KEYRELEASE_ID, /* Keyboard button released */ IECODE_ENTER_ID, /* Mouse entered object */ IECODE_LEAVE_ID, /* Mouse left object */ _IECODE_NUM /* Number of possible events types */ } IHEventCode;
This type enumerates all of the possible action codes that an event can be. The exact interpretation and validity of these codes depends on the class of the event they are used in.
IHEvent* BR_AllocEvent(IHGlobalInfo*
gi, IHDocument doc, IHLangEnv* langenv,
IHEventClass class, IHEventCode code, void* object)
(IHGlobalInfo*)
gi
(IHDocument)
doc
(IHLangEnv*)
langenv
(IHEventClass)
class
(IHEventCode)
code
(void*)
object
(IHEvent*)
A newly created
event.
Creates a new event with the given attributes. The program may then perform set/get operations on any appropriate attributes. Not that all of these arguments are constants for an event, and should not be changed after the event is created.
IHEvent* BR_DupEvent(IHEvent*
orig)
(IHEvent*)
orig
(IHEvent*)
A newly created
event, that is identical to orig
Creates a new event that is a duplicate of the given existing event.
void BR_FreeEvent(IHEvent* event)
(IHEvent*)
event
Frees an event previously allocated with BR_AllocEvent() or BR_DupEvent().
void BR_FreeEventAttr(IHEvent*
event, IHEventAttr attr, IHAttrType type, IHAttrVal
value)
(IHEvent*)
event
(IHEventAttr)
attr
(IHAttrType)
type
(IHAttrVal)
value
Deallocates any memory associated with the given attribute, which had previously been obtained with BR_GetEventAttr().
IHAttrType BR_GetEventAttr(IHEvent*
event, IHEventAttr attr, IHAttrVal* value)
(IHEvent*)
event
(IHEventAttr)
attr
(IHAttrVal*)
value
(IHAttrType)
The type of the
returned attribute value, or ATTRTYPE_NONE for failure.
Returns the value of an attribute associated with the given browser event. The type of the attribute is the return code; a type of ATTRTYPE_NONE indicates that the attribute doesn't exist.
A program must call BR_FreeEventAttr() on all attributes it retrieves, when it is done with them.
void BR_SetEventAttr(IHEvent*
event, IHEventAttr attr, IHAttrType type, IHAttrVal
value)
(IHEvent*)
event
(IHEventAttr)
attr
(IHAttrType)
type
(IHAttrVal)
value
Sets an event's attribute to the given value.
[Home] [ToC] [Up] [Prev] [Next]
Dianne Kyra Hackborn <hackbod@angryredplanet.com> | Last modified: Tue Oct 8 04:00:43 PDT 1996 |