Mac OS 9
Events.h File Reference

Event Manager Interfaces. More...

#include <OSUtils.h>
#include <Quickdraw.h>
#include <MacTypes.h>
#include <Endian.h>

Go to the source code of this file.

Data Structures

struct  EventRecord
 
struct  EvQEl
 

Macros

#define NewFKEYUPP(userRoutine)
 
#define DisposeFKEYUPP(userUPP)   DisposeRoutineDescriptor(userUPP)
 
#define InvokeFKEYUPP(userUPP)    CALL_ZERO_PARAMETER_UPP((userUPP), uppFKEYProcInfo)
 
#define NewFKEYProc(userRoutine)   NewFKEYUPP(userRoutine)
 
#define CallFKEYProc(userRoutine)   InvokeFKEYUPP(userRoutine)
 
#define NewGetNextEventFilterUPP(userRoutine)
 
#define DisposeGetNextEventFilterUPP(userUPP)   DisposeRoutineDescriptor(userUPP)
 
#define InvokeGetNextEventFilterUPP(theEvent, result, userUPP)
 
#define NewGetNextEventFilterProc(userRoutine)    NewGetNextEventFilterUPP(userRoutine)
 
#define CallGetNextEventFilterProc(userRoutine, theEvent, result)    InvokeGetNextEventFilterUPP(theEvent, result, userRoutine)
 

Typedefs

typedef UInt16 EventKind
 
typedef UInt16 EventMask
 
typedef UInt16 EventModifiers
 
typedef struct EventRecord EventRecord
 
typedef BigEndianLong KeyMap[4]
 
typedef UInt8 KeyMapByteArray[16]
 
typedef struct EvQEl EvQEl
 
typedef EvQElEvQElPtr
 
typedef GetNextEventFilterUPP GNEFilterUPP
 
typedef struct OpaqueEventRef * EventRef
 

Enumerations

enum  {
  nullEvent = 0 , mouseDown = 1 , mouseUp = 2 , keyDown = 3 ,
  keyUp = 4 , autoKey = 5 , updateEvt = 6 , diskEvt = 7 ,
  activateEvt = 8 , osEvt = 15 , kHighLevelEvent = 23
}
 
enum  {
  mDownMask = 1 << mouseDown , mUpMask = 1 << mouseUp , keyDownMask = 1 << keyDown , keyUpMask = 1 << keyUp ,
  autoKeyMask = 1 << autoKey , updateMask = 1 << updateEvt , diskMask = 1 << diskEvt , activMask = 1 << activateEvt ,
  highLevelEventMask = 0x0400 , osMask = 1 << osEvt , everyEvent = 0xFFFF
}
 
enum  { charCodeMask = 0x000000FF , keyCodeMask = 0x0000FF00 , adbAddrMask = 0x00FF0000 , osEvtMessageMask = (unsigned long)0xFF000000 }
 
enum  { mouseMovedMessage = 0x00FA , suspendResumeMessage = 0x0001 }
 
enum  { resumeFlag = 1 }
 
enum  { convertClipboardFlag }
 
enum  {
  activeFlagBit = 0 , btnStateBit = 7 , cmdKeyBit = 8 , shiftKeyBit = 9 ,
  alphaLockBit = 10 , optionKeyBit = 11 , controlKeyBit = 12 , rightShiftKeyBit = 13 ,
  rightOptionKeyBit = 14 , rightControlKeyBit = 15
}
 
enum  {
  activeFlag = 1 << activeFlagBit , btnState = 1 << btnStateBit , cmdKey = 1 << cmdKeyBit , shiftKey = 1 << shiftKeyBit ,
  alphaLock = 1 << alphaLockBit , optionKey = 1 << optionKeyBit , controlKey = 1 << controlKeyBit , rightShiftKey = 1 << rightShiftKeyBit ,
  rightOptionKey = 1 << rightOptionKeyBit , rightControlKey = 1 << rightControlKeyBit
}
 
enum  {
  kNullCharCode = 0 , kHomeCharCode = 1 , kEnterCharCode = 3 , kEndCharCode = 4 ,
  kHelpCharCode = 5 , kBellCharCode = 7 , kBackspaceCharCode = 8 , kTabCharCode = 9 ,
  kLineFeedCharCode = 10 , kVerticalTabCharCode = 11 , kPageUpCharCode = 11 , kFormFeedCharCode = 12 ,
  kPageDownCharCode = 12 , kReturnCharCode = 13 , kFunctionKeyCharCode = 16 , kCommandCharCode = 17 ,
  kCheckCharCode = 18 , kDiamondCharCode = 19 , kAppleLogoCharCode = 20 , kEscapeCharCode = 27 ,
  kClearCharCode = 27 , kLeftArrowCharCode = 28 , kRightArrowCharCode = 29 , kUpArrowCharCode = 30 ,
  kDownArrowCharCode = 31 , kSpaceCharCode = 32 , kDeleteCharCode = 127 , kBulletCharCode = 165 ,
  kNonBreakingSpaceCharCode = 202
}
 
enum  {
  kShiftUnicode = 0x21E7 , kControlUnicode = 0x2303 , kOptionUnicode = 0x2325 , kCommandUnicode = 0x2318 ,
  kPencilUnicode = 0x270E , kCheckUnicode = 0x2713 , kDiamondUnicode = 0x25C6 , kBulletUnicode = 0x2022 ,
  kAppleLogoUnicode = 0xF8FF
}
 
enum  { uppFKEYProcInfo = 0x00000000 }
 
enum  {
  networkEvt = 10 , driverEvt = 11 , app1Evt = 12 , app2Evt = 13 ,
  app3Evt = 14 , app4Evt = 15 , networkMask = 0x0400 , driverMask = 0x0800 ,
  app1Mask = 0x1000 , app2Mask = 0x2000 , app3Mask = 0x4000 , app4Mask = 0x8000
}
 
enum  { uppGetNextEventFilterProcInfo = 0x000000BF }
 

Functions

typedef CALLBACK_API (void, FKEYProcPtr)(void)
 
typedef STACK_UPP_TYPE (FKEYProcPtr) FKEYUPP
 
FKEYUPP NewFKEYUPP (FKEYProcPtr userRoutine)
 
void DisposeFKEYUPP (FKEYUPP userUPP)
 
void InvokeFKEYUPP (FKEYUPP userUPP)
 
void GetMouse (Point *mouseLoc)
 
Boolean Button (void)
 
Boolean StillDown (void)
 
Boolean WaitMouseUp (void)
 
UInt32 KeyTranslate (const void *transData, UInt16 keycode, UInt32 *state)
 
UInt32 GetCaretTime (void)
 Obtain insertion-point cursor blink interval. More...
 
void GetKeys (KeyMap theKeys)
 
typedef CALLBACK_API_REGISTER68K (void, GetNextEventFilterProcPtr,(EventRecord *theEvent, Boolean *result))
 
typedef REGISTER_UPP_TYPE (GetNextEventFilterProcPtr) GetNextEventFilterUPP
 
GetNextEventFilterUPP NewGetNextEventFilterUPP (GetNextEventFilterProcPtr userRoutine)
 
void DisposeGetNextEventFilterUPP (GetNextEventFilterUPP userUPP)
 
void InvokeGetNextEventFilterUPP (EventRecord *theEvent, Boolean *result, GetNextEventFilterUPP userUPP)
 
 if (theEvent.what==keyDown)
 Find max delay between clicks of a double click. More...
 
 EventLoop ()
 
DAs wanting a timeslice every so often should set bit of the drvrFlags word and a tick count in drvrDelay in the driver header You should not depend on any particular since an application may fail to call SystemTask often enough (e.g., when saving a file) .To receive periodic timeslices with more accuracy
 
Boolean SystemEvent (const EventRecord *theEvent)
 Used internally by Event Manager. More...
 
void GetGlobalMouse (Point *globalMouse)
 
UInt32 GetCurrentKeyModifiers (void)
 
Boolean CheckEventQueueForUserCancel (void)
 
void KeyScript (short code)
 
Boolean IsCmdChar (const EventRecord *event, short test)
 
SInt16 LMGetKeyThresh (void)
 
void LMSetKeyThresh (SInt16 value)
 
SInt16 LMGetKeyRepThresh (void)
 
void LMSetKeyRepThresh (SInt16 value)
 
UInt8 LMGetKbdLast (void)
 
void LMSetKbdLast (UInt8 value)
 
UInt8 LMGetKbdType (void)
 
void LMSetKbdType (UInt8 value)
 

Variables

DAs wanting a timeslice every so often should set bit of the drvrFlags word and a tick count in drvrDelay in the driver header You should not depend on any particular accuracy
 
DAs wanting a timeslice every so often should set bit of the drvrFlags word and a tick count in drvrDelay in the driver header You should not depend on any particular since an application may fail to call SystemTask often install a vertical retrace task via VInstall or a timer interrupt task via InsTime</pre > *par Copyright
 

Detailed Description

Event Manager Interfaces.

Introduced In: Mac OS 8
Avaliable From: Universal Interfaces 3.4.1
Copyright: © 1985-2001 by Apple Computer, Inc., all rights reserved

For bug reports, consult the following page on the World Wide Web:

http://developer.apple.com/bugreporter/

Macro Definition Documentation

◆ InvokeGetNextEventFilterUPP

#define InvokeGetNextEventFilterUPP (   theEvent,
  result,
  userUPP 
)
Value:
CALL_TWO_PARAMETER_UPP((userUPP), uppGetNextEventFilterProcInfo, (theEvent), \
(result))
Definition: Events.h:224

◆ NewFKEYProc

#define NewFKEYProc (   userRoutine)    NewFKEYUPP(userRoutine)

CALL_NOT_IN_CARBON support for pre-Carbon UPP routines: New...Proc and Call...Proc

◆ NewFKEYUPP

#define NewFKEYUPP (   userRoutine)
Value:
(FKEYUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFKEYProcInfo, \
GetCurrentArchitecture())
UniversalProcPtr NewRoutineDescriptor(ProcPtr theProc, ProcInfoType theProcInfo, ISAType theISA)

pascal no_return_value Func()

◆ NewGetNextEventFilterProc

#define NewGetNextEventFilterProc (   userRoutine)     NewGetNextEventFilterUPP(userRoutine)

CALL_NOT_IN_CARBON support for pre-Carbon UPP routines: New...Proc and Call...Proc

◆ NewGetNextEventFilterUPP

#define NewGetNextEventFilterUPP (   userRoutine)
Value:
(GetNextEventFilterUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), \
uppGetNextEventFilterProcInfo, \
GetCurrentArchitecture())

SPECIAL_CASE_PROCINFO(11)

Typedef Documentation

◆ EventKind

typedef UInt16 EventKind

!TARGET_OS_MAC || !TARGET_API_MAC_OS8

◆ EventModifiers

typedef UInt16 EventModifiers

CALL_NOT_IN_CARBON CARBON ALERT! BATTLESTATIONS!

The EventModifiers bits defined here are also used in the newer Carbon Event key modifiers parameters. There are two main differences:

1) The Carbon key modifiers parameter is a UInt32, not a UInt16. Never try to extract the key modifiers parameter from a Carbon Event into an EventModifiers type. You will probably get your stack trashed. 2) The Carbon key modifiers is just that: key modifiers. That parameter will never contain the button state bit.

◆ EventRef

typedef struct OpaqueEventRef* EventRef

The core data structure for the Carbon event system. It is declared here instead of in CarbonEvents.h to avoid recursive include problems.

◆ GNEFilterUPP

typedef GetNextEventFilterUPP GNEFilterUPP

CALL_NOT_IN_CARBON

◆ KeyMap

typedef BigEndianLong KeyMap[4]

QuickTime 3.0 supports GetKeys() on unix and win32 But, on little endian machines you will have to be careful about bit numberings and/or use a KeyMapByteArray instead.

◆ KeyMapByteArray

typedef UInt8 KeyMapByteArray[16]

TARGET_OS_MAC && TARGET_API_MAC_OS8

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
activateEvt 

Not sent in Carbon. See kEventClassVolume in CarbonEvents.h

◆ anonymous enum

anonymous enum
Enumerator
mUpMask 

mouse button pressed

keyDownMask 

mouse button released

keyUpMask 

key pressed

autoKeyMask 

key released

updateMask 

key repeatedly held down

diskMask 

window needs updating

activMask 

disk inserted

highLevelEventMask 

activate/deactivate window

osMask 

high-level events (includes AppleEvents)

everyEvent 

operating system events (suspend, resume)

◆ anonymous enum

anonymous enum
Enumerator
mouseMovedMessage 

OS event messages. Event (sub)code is in the high byte of the message field.

◆ anonymous enum

anonymous enum

convertClipboardFlag is not ever set under Carbon. This is because scrap conversion is
not tied to suspend/resume events any longer. Your application should instead use the
scrap promise mechanism and fulfill scrap requests only when your promise keeper proc
is called. If you need to know if the scrap has changed, you can cache the last
ScrapRef you received and compare it with the current ScrapRef

◆ anonymous enum

anonymous enum
Enumerator
activeFlagBit 

modifiers

btnStateBit 

activate? (activateEvt and mouseDown)

cmdKeyBit 

state of button?

shiftKeyBit 

command key down?

alphaLockBit 

shift key down?

optionKeyBit 

alpha lock down?

controlKeyBit 

option key down?

rightShiftKeyBit 

control key down?

rightOptionKeyBit 

right shift key down?

rightControlKeyBit 

right Option key down?

◆ anonymous enum

anonymous enum

MacRoman character codes

Enumerator
kCheckCharCode 

glyph available only in system fonts

kDiamondCharCode 

glyph available only in system fonts

kAppleLogoCharCode 

glyph available only in system fonts

kEscapeCharCode 

glyph available only in system fonts

◆ anonymous enum

anonymous enum

useful Unicode code points

Enumerator
kControlUnicode 

Unicode UPWARDS WHITE ARROW

kOptionUnicode 

Unicode UP ARROWHEAD

kCommandUnicode 

Unicode OPTION KEY

kPencilUnicode 

Unicode PLACE OF INTEREST SIGN

kCheckUnicode 

Unicode LOWER RIGHT PENCIL

kDiamondUnicode 

Unicode CHECK MARK

kBulletUnicode 

Unicode BLACK DIAMOND

kAppleLogoUnicode 

Unicode BULLET

◆ anonymous enum

anonymous enum

Obsolete event types & masks

Function Documentation

◆ Button()

Boolean Button ( void  )

Button()

Non-Carbon CFM: in InterfaceLib 7.1 and later
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ CheckEventQueueForUserCancel()

Boolean CheckEventQueueForUserCancel ( void  )

CheckEventQueueForUserCancel()

Summary: Determines if there is a cancel event in the event queue.

Discussion: This API supports two cancel events: Escape and Cmd-Period. Mouse or keyboard events in front of the cancel event in the event queue will be removed.

Non-Carbon CFM: not available
Carbon Lib: in CarbonLib 1.0.2 and later
Mac OS X: in version 10.0 and later

◆ DisposeFKEYUPP()

void DisposeFKEYUPP ( FKEYUPP  userUPP)

DisposeFKEYUPP()

Non-Carbon CFM: available as macro/inline
Carbon Lib: not available
Mac OS X: not available

◆ DisposeGetNextEventFilterUPP()

void DisposeGetNextEventFilterUPP ( GetNextEventFilterUPP  userUPP)

DisposeGetNextEventFilterUPP()

Non-Carbon CFM: available as macro/inline
Carbon Lib: not available
Mac OS X: not available

◆ GetCaretTime()

UInt32 GetCaretTime ( void  )

Obtain insertion-point cursor blink interval.

GetCaretTime returns the amount of time, in 1/60-th second ( 16.66 ms)
ticks, between blinks of the text-editing insertion point caret (normally a
vertical bar).
Returns
a 32-bit long; the caret blink interval, as set by the user via the
Control Panel DA.
Note
Another way to access this information is by reading the global variable
CaretTime (at 0x02F4).
If you use TextEdit, the caret blinking is automatic (if you call TEIdle
appropriately). Otherwise, you should check the elapsed ticks at each pass
through your main event loop, and toggle the display on or off as each
CaretTime -tick interval elapses.
Copyright: THINK Reference © 1991-1992 Symantec Corporation
Non-Carbon CFM: in InterfaceLib 7.1 and later
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ GetCurrentKeyModifiers()

UInt32 GetCurrentKeyModifiers ( void  )

GetCurrentKeyModifiers()

Summary: Returns the current state of the keyboard modifier keys.

Discussion: The format of the return value is the same as the modifiers field of the EventRecord.

Non-Carbon CFM: not available
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ GetGlobalMouse()

void GetGlobalMouse ( Point globalMouse)

CALL_NOT_IN_CARBON OLDROUTINENAMES GetGlobalMouse, GetCurrentKeyModifiers, and CheckEventQueueForUserCancel are only available as part of the Carbon API. GetGlobalMouse()

Summary: Returns the position of the mouse in global coordinates.

Parameters:

globalMouse: On exit, contains the mouse position in global coordinates.

Non-Carbon CFM: in CarbonAccessors.o 1.0 and later
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ GetKeys()

void GetKeys ( KeyMap  theKeys)

GetKeys()

Non-Carbon CFM: in InterfaceLib 7.1 and later
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ GetMouse()

void GetMouse ( Point mouseLoc)

CALL_NOT_IN_CARBON GetMouse()

Non-Carbon CFM: in InterfaceLib 7.1 and later
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ if()

if ( theEvent.  what = = keyDown)

Find max delay between clicks of a double click.

GetDblTime returns an interval of time, in ticks. If two mouseDown events
occur within this interval and are close together, the combined events should
be considered a double click.
Returns
a 32-bit long; the suggested maximum interval, in 1/60th-second
ticks, between a mouse up and the following mouseDown , that should
constitute a double click.
Note
Another way to get this information is to access the global variable
DoubleTime directly.  The interval is adjustable by the user via the
Control Panel DA.
If you compare the EventRecord .when and the EventRecord .where of any
two mouseDown events and the second is less than DoubleTime ticks older
than the first and the points of occurrence are within 5 pixels, it should be
considered a double click. The following example illustrates how to detect a
double click.
Example
#include < Events.h>
#include <stdlib.h>
void DoDoubleClick ( EventRecord theEvent);
long lastWhen = 0;
Point lastWhere = {0,0};
EventRecord theEvent;
while (TRUE) {
GetNextEvent ( everyEvent , &theEvent );
if ( theEvent.what == mouseDown ) {
if ( ( (theEvent.when - lastWhen) < DoubleTime )
&& ( abs(theEvent.where.h-lastWhere.h) < 5 )
&& ( abs(theEvent.where.v-lastWhere.v) < 5 ) ) {
DoDoubleClick( &theEvent ); // process the double click
}
lastWhen = theEvent.when;
lastWhere = theEvent.where;
/ ... handle other mouseDown events ... 

Set the system event mask

SetEventMask sets the low-level mask used by the system to determine
which events it should post to the event queue.
eventMask is a 16-bit binary mask describing which events to include or
exclude. The normal value is 0xFFEF (which excludes only keyUp
events). Use eventMask =everyEvent (defined in Events.h as 0xFFFF)
to include all events. See Event Mask for named constants you can
use in this value.
Returns
none
Note
The preferred way to access the system event mask is by reading or storing
the global variable SysEvtMask (at 0x0144).
Indiscriminately changing this mask can cause problems. The only
legitimate use is to allow enqueuing of keyUp events, i.e.:
SetEventMask ( everyEvent ); // or SysEvtMask |= keyUpMask
Applications making this call during initialization must save the event
mask prior to calling SetEventMask and restore the event mask when
quitting.
If, under Finder, an application fails to restore the event mask before
quitting and it was set to mask out mouseUp events, all mouseUp events
would continue to be masked out. The user would then notice that the Finder
no longer recognizes double clicks. There are other anomalies associated
with MultiFinder ; to get a summary of these see the entry
About MultiFinder .
Copyright: THINK Reference © 1991-1992 Symantec Corporation
Non-Carbon CFM: in InterfaceLib 7.1 and later
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

Get address of event queue header

GetEvQHdr returns the address of the event queue header. This gives you
direct access to the event queue, in case you want more complete control than
provided by PostEvent and GetNextEvent .
Returns
a QHdrPtr; the address of the queue header of the system event
queue.
Note
This simply returns the value 0x014A - the address of the global variable
EventQueue .
See Enqueue and Dequeue for information on how to access elements of a
queue.
Copyright: THINK Reference © 1991-1992 Symantec Corporation
Non-Carbon CFM: in InterfaceLib 7.1 and later
Carbon Lib: not available
Mac OS X: not available

CALL_NOT_IN_CARBON

Enqueue an event and get its address

PPostEvent works like PostEvent (it stores an entry into the
event queue) except that it returns, via its third parameter, the physical
address of the stored queue element. This provides access so you can modify the
contents of that element.
eventWhat specifies which type of event should be posted. It should be one of
the event types listed in GetNextEvent .
eventMsg specifies the value to be placed in the message field of the
EventRecord . It should correspond in type to the meaning of
eventWhat .
qElPtris the address of an EvQElPtr . Upon return, it contains the address
of a 22-byte evQEl structure. See Notes, below for an example of
how to access that record.
Returns
an Error Code . The following are possible:
noErr(0)worked without error
evtNotEnb (1)eventWhat  is currently disabled. See SetEventMask
Note
The less-flexible PostEvent function lets you specify values for only two
of the five EventRecord fields. By using PPostEvent , you can follow up by
changing the where, when, and modifiers fields.
For instance, you could use PPostEvent to enqueue a command-key
shifted mouseDown event with selected coordinates as follows:
EvQEl*myQElPtr;
PPostEvent ( mouseDown , 0, &myQElPtr );
myQElPtr-> evtQModifiers = cmdKey;
SetPt( &(myQElPtr->evtQWhere), 100,100);
See EvQEl for the layout of event queue elements.
It is also possible to build a queue element from scratch and use Enqueue
to insert it into the event queue. See GetEvQHdr .
Copyright: THINK Reference © 1991-1992 Symantec Corporation
Non-Carbon CFM: in InterfaceLib 7.1 and later
Carbon Lib: not available
Mac OS X: not available

CALL_NOT_IN_CARBON

GetNextEvent()

Non-Carbon CFM: in InterfaceLib 7.1 and later
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

WaitNextEvent()

Non-Carbon CFM: in InterfaceLib 7.1 and later
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

can be NULL

EventAvail()

Non-Carbon CFM: in InterfaceLib 7.1 and later
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

Place an EventRecord in the event queue

PostEvent stores an EventRecord into the event queue where it can be read
via GetNextEvent , EventAvail or WaitNextEvent .
eventWhat specifies which type of event should be posted. It should be one of
the event types listed in Event Types . Typically, this will be the
app3Evt event
eventMsg specifies the value to be placed in the message field of the
EventRecord . It should correspond in type to the meaning of
eventWhat . For instance, in keyUp and keyDown events, the high
word is 0, and the low word is a scan code and character code. For
application-defined events, this can be any 32-bit value, such as a
handle to a bunch of data.
Returns
a System Error Code . The following are possible:
noErr(0)worked without error
evtNotEnb (1)eventWhat  is disabled. See SetEventMask
Note
PostEvent creates the EventRecord using the current time, modifiers ,
and mouse position. If you need to control these values, you may have to
modify the queue itself. See PPostEvent for a way to alter the EventRecord
after it is enqueued and see GetEvQHdr for additional information.
It is probably unwise to post window update and activate events ( updateEvt
or activateEvt ) since these are actually generated by the Event Manager
at the time of the GetNextEvent request, and are never actually stored in
the queue.
An example of usage might be to post a menu-changing event. For instance,
define an app3Evt to be one that causes a window name to be added or
removed from your application's Window menu. You could use
PostEvent (app3Evt, windowID ) whenever the user opens or closes a
document window. That way, you can handle all window-related menu
manipulation as a function of your main event loop . Note: This is not
necessarily a better way to do it, just an alternative.
Copyright: THINK Reference © 1991-1992 Symantec Corporation
Non-Carbon CFM: in InterfaceLib 7.1 and later
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

For Carbon, use EventAvail, TickCount, GetGlobalMouse, GetKeys, or GetCurrentKeyModifiers instead of OSEventAvail, and use GetNextEvent or WaitNextEvent instead of GetOSEvent.

Low-level read event without dequeuing it

OSEventAvail is identical to GetOSEvent except that it does not remove the
event from the event queue. This lets you check for the occurrence of a
specific event (or any event) but leave it in the queue for later processing.
eventMask is a 16-bit binary mask describing which events to
include/exclude. Use eventMask =everyEvent (defined as -1) to
include all events. See Event Mask for the layout.
Some events (e.g., keyUp events) may never make it into the event
queue. See SetEventMask .
theEvent is the address of a 16-byte EventRecord . Upon return, it is filled
with an event description. See GetNextEvent .
Returns
a Boolean value; it identifies whether a requested event was found.
It will be one of:
FALSEThis is a null event or one you did not request. Ignore it.
TRUEThis event is intended for you. Examine and respond.
Note
In a busy system, it is possible that an event read via this call will be
discarded before it can be processed. The Event Manager usually keeps
only 20 events, scrapping the oldest unread events to make room for new
ones.
Copyright: THINK Reference © 1991-1992 Symantec Corporation
Non-Carbon CFM: in InterfaceLib 7.1 and later
Carbon Lib: not available
Mac OS X: not available

Low-level read event and remove event from event queue

GetOSEvent is identical to OSEventAvail except that removes the event
from the event queue. Unlike GetNextEvent or WaitNextEvent ,
GetOSEvent doesn't call the Desk Manager to see if the system wants to
intercept and respond to the event, nor does it perform GetNextEvent 's or
WaitNextEvent 's processing of the alarm and Command-Shift-number
combinations.
eventMask is a 16-bit binary mask describing which events to
include/exclude. Use eventMask =everyEvent (defined as -1) to
include all events. See GetNextEvent for the layout.
Some events (e.g., keyUp events) may never make it into the
event queue. See SetEventMask .
theEvent is the address of a 16-byte EventRecord . Upon return, it is filled
with an event description. See GetNextEvent or WaitNextEvent .
Returns
a Boolean value; it identifies whether a requested event was found.
It will be one of:
FALSEThis is a null event or one you did not request. Ignore it.
TRUEThis event is intended for you. Examine and respond.
Note
The Event Manager usually keeps only 20 events, scrapping the oldest
unread events to make room for new ones.
Copyright: THINK Reference © 1991-1992 Symantec Corporation
Non-Carbon CFM: in InterfaceLib 7.1 and later
Carbon Lib: not available
Mac OS X: not available

CALL_NOT_IN_CARBON

Discard all or selected events from event queue

FlushEvents discards all (or selected) events chronologically, until it hits
a specified event type . It is often used at the beginning of a program to empty
the event queue of spurious keystrokes or clicks left over from the Finder.
eventMask specifies which event(s) should be flushed. It is a 16-bit binary
mask where a 1 elects to flush an event and a 0 keeps the event. The
most common usage is to use eventMask =everyEvent , defined in
Events.h as 0xFFFF. See Event Mask for details.
stopMask specifies which events (if any) should stop the flushing process.
For instance, if you want to discard all events up to the next
keystroke, use stopMask = keyDown . A value of 0 means to keep
flushing to the end of the queue.
Returns
none
Note
To purge all events from the queue, use:
FlushEvents ( everyEvent , 0 );
Note: FlushEvents will not remove pending highLevelEvents.
Copyright: THINK Reference © 1991-1992 Symantec Corporation
Non-Carbon CFM: in InterfaceLib 7.1 and later
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

SystemClick()

Non-Carbon CFM: in InterfaceLib 7.1 and later
Carbon Lib: not available
Mac OS X: not available

Give DAs a chance to perform periodic actions

Call SystemTask at least once each time through your event loop. It lets the
Desk Manager process such periodic DA events as updating the display of a
clock.
Returns
none
Note
SystemTask should be called at least once every 17ms (1/60-th of a
second).  Normal usage is to put it inside a part of the event loop that
always gets executed:
main()
{
InitGraf ();.... initialize other stuff ...while (TRUE) /* Loop forever; terminate via 
 

◆ InvokeFKEYUPP()

void InvokeFKEYUPP ( FKEYUPP  userUPP)

InvokeFKEYUPP()

Non-Carbon CFM: available as macro/inline
Carbon Lib: not available
Mac OS X: not available

◆ InvokeGetNextEventFilterUPP()

void InvokeGetNextEventFilterUPP ( EventRecord theEvent,
Boolean result,
GetNextEventFilterUPP  userUPP 
)

InvokeGetNextEventFilterUPP()

Non-Carbon CFM: available as macro/inline
Carbon Lib: not available
Mac OS X: not available

◆ IsCmdChar()

Boolean IsCmdChar ( const EventRecord event,
short  test 
)

IsCmdChar()

Non-Carbon CFM: in InterfaceLib 7.1 and later
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ KeyScript()

void KeyScript ( short  code)

KeyScript()

Non-Carbon CFM: in InterfaceLib 7.1 and later
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ KeyTranslate()

UInt32 KeyTranslate ( const void *  transData,
UInt16  keycode,
UInt32 *  state 
)

KeyTranslate()

Non-Carbon CFM: in InterfaceLib 7.1 and later
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ LMGetKbdLast()

UInt8 LMGetKbdLast ( void  )

LMGetKbdLast()

Non-Carbon CFM: in InterfaceLib 7.1 and later
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ LMGetKbdType()

UInt8 LMGetKbdType ( void  )

LMGetKbdType()

Non-Carbon CFM: in InterfaceLib 7.1 and later
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ LMGetKeyRepThresh()

SInt16 LMGetKeyRepThresh ( void  )

LMGetKeyRepThresh()

Non-Carbon CFM: in InterfaceLib 7.1 and later
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ LMGetKeyThresh()

SInt16 LMGetKeyThresh ( void  )

LowMem accessor functions previously in LowMem.h LMGetKeyThresh()

Non-Carbon CFM: in InterfaceLib 7.1 and later
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ LMSetKbdLast()

void LMSetKbdLast ( UInt8  value)

LMSetKbdLast()

Non-Carbon CFM: in InterfaceLib 7.1 and later
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ LMSetKbdType()

void LMSetKbdType ( UInt8  value)

LMSetKbdType()

Non-Carbon CFM: in InterfaceLib 7.1 and later
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ LMSetKeyRepThresh()

void LMSetKeyRepThresh ( SInt16  value)

LMSetKeyRepThresh()

Non-Carbon CFM: in InterfaceLib 7.1 and later
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ LMSetKeyThresh()

void LMSetKeyThresh ( SInt16  value)

LMSetKeyThresh()

Non-Carbon CFM: in InterfaceLib 7.1 and later
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ NewFKEYUPP()

FKEYUPP NewFKEYUPP ( FKEYProcPtr  userRoutine)

NewFKEYUPP()

Non-Carbon CFM: available as macro/inline
Carbon Lib: not available
Mac OS X: not available

◆ NewGetNextEventFilterUPP()

GetNextEventFilterUPP NewGetNextEventFilterUPP ( GetNextEventFilterProcPtr  userRoutine)

NewGetNextEventFilterUPP()

Non-Carbon CFM: available as macro/inline
Carbon Lib: not available
Mac OS X: not available

◆ StillDown()

Boolean StillDown ( void  )

StillDown()

Non-Carbon CFM: in InterfaceLib 7.1 and later
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later

◆ SystemEvent()

Boolean SystemEvent ( const EventRecord theEvent)

Used internally by Event Manager.

SystemEvent is called by the Event Manager as a way to watch for certain
events and pass some of them directly to DAs, without bothering your
application. This function should not be called by applications.
theEvent is the address of a 16-byte EventRecord . It contains information
received from a previous call to GetNextEvent .
Returns
A Boolean; it identifies whether the event should be handled by an
application or a DA. It is one of:
FALSE (0)This event should be passed to the application. It may be a
system event the application should handle by calling
SystemClick .
TRUE (1)This event should be handled by the system (i.e., a DA). It will
not be forwarded to the application.
Note
SystemEvent is called internally by the GetNextEvent function. The
idea is to avoid clogging up your event loop; let the system handle such
events as keystrokes, mouse-ups, updates, and activate events occuring in a
DA window.
If you want to get a look at all events, you can store a 0 in the 1-byte
global variable SEvtEnb (at 0x015c). This will cause GetNextEvent to
forward all unmasked events to you.
When a DA creates a window (including a modeless dialog) it must set the
windowKind to its refnum, which is a negative number. When the
application calls GetNextEvent , as explained above, the Event Manager
calls SystemEvent . If it returns TRUE then your DA gets the event. Since
your window is a modeless dialog you would call IsDialogEvent , which
returns FALSE What is going on is that IsDialogEvent (like
SystemEvent) checks the windowKind looking for a value of 2 (for
dialogs). Since your dialog's windowKind is a negative number, the DA's
refnum, IsDialogEvent does nothing. The solution is to change the
windowKind of your window to 2 before calling IsDialogEvent . This
allows the Dialog Manager to recognize and handle the event properly. Be
sure to restore the windowKind to its former value before returning to
SystemEvent . That way, when the application calls the Dialog Manager
with the same event (it should pass all events to the Dialog Manager if it has
any modeless dialogs), the Dialog Manager will ignore it.
Copyright: THINK Reference © 1991-1992 Symantec Corporation
Non-Carbon CFM: in InterfaceLib 7.1 and later
Carbon Lib: not available
Mac OS X: not available

◆ WaitMouseUp()

Boolean WaitMouseUp ( void  )

WaitMouseUp()

Non-Carbon CFM: in InterfaceLib 7.1 and later
Carbon Lib: in CarbonLib 1.0 and later
Mac OS X: in version 10.0 and later