These primitives are used by the System Classes to aid in event handling. They are described here for advanced users who need to change the default behavior of System Classes or require more direct control over event handling.
_________________________________________________
 
sc-activate-wind *346*
Input types: Window; Boolean
Description: Performs activate functions necessary for text editors and scrolling lists. sc-activate-wind is called when a window is activated or deactivated.
If the selected item is an Edit Text or a Scroll Text, sc-activate-wind calls TEActivate or TEDeactivate, depending on the value of Activate
If the selected item is a Scroll List, its selection border is invalidated. When Activate is FALSE the border is erased before being invalidated.
If the Window has a grow box, sc-activate-wind makes sure the grow box is redrawn by invalidating the grow box region.
Description: Accepts an Apple Event from the Event Manager, and extracts its Message, Reply, Class and Id.
Message contains all of the information associated with the Apple event. Reply is a default reply which is automatically returned to the sender of the Apple event when sc-aevent-end is called. Error is zero if the primitive succeeds, otherwise error is an Apple event Manager error code.
sc-aevent-begin should always be matched by a call to sc-aevent-end. This ensures that the memory associated with the Message and Reply is properly released.
sc-aevent-begin calls AEProcessAppleEvent, to accept the event; AESuspendTheCurrentEvent, to prevent the reply from being sent; and then AESetTheCurrentEvent to make the event the current Apple event.
_________________________________________________
 
sc-aevent-dispatch *347*
Input types: Integer; Integer
Output types: String
Description: Searches the current Application’s aevent methods attribute and returns the MethodName which matches the Class and Id (or NULL if no match is found).
sc-aevent-dispatch does not call the method; it provides a convenient way to search the Application’s aevent methods.
_________________________________________________
 
sc-aevent-end *347*
Input names: Message; Reply; ReplyError
Input types: AppleEvent; AppleEvent; Integer
Output names: Error
Output types: Integer
Description: Finishes the processing of an Apple event. The Reply is sent, if necessary, and the memory occupied by Message and Reply is released. Error is zero if the primitive succeeds.
sc-aevent-end adds ReplyError to Reply and then calls AEResumeTheCurrentEvent to send Reply to the sender of the Apple event. If you have successfully handled the Apple event, ReplyError should be zero.
_________________________________________________
  sc-background? *348*
Output names: [TheResult]
Output types: [boolean]
Description: Determines if your application is running in the background under MultiFinder or System 7. With output TheResult is TRUE or FALSE. Without output the primitive succeeds or fails.
_________________________________________________
 
sc-begin-drawing *348*
Input types: Canvas
Output types: ABlock
Description: Prepares a Canvas for drawing and saves its graphical state. Used in conjunction with sc-end-drawing.
You should call sc-begin-drawing before drawing in a Canvas. However, the System Class methods do this for you before calling the draw method of a Canvas.
sc-begin-drawing sets the port to the port of the Canvas’s owning window; sets the origin of the window so that {0 0} is at the top left corner of the Canvas; and sets the clip region to the Canvas’s rectangle. All of the window’s port information is saved in CanvasState.
_________________________________________________
 
sc-begin-update *348*
Input types: Window
Output types: ABlock
Description: Prepares a window for updating and saves its graphical state. Used in conjunction with sc-end-update.
sc-begin-update is called in response to an update event for a window. Update events are created automatically when a part of a window is exposed (by closing a window which overlaps another window, for example ). Update events can also be generated by the programmer using the Macintosh Toolbox calls InvalRect and InvalRgn.
sc-begin-update sets the visible region of a window so that drawing only occurs in the area that needs updating. sc-end-update restores the visible region, so every call to sc-begin-update should be matched by a call to sc-end-update.
sc-begin-update sets the port to the window’s GrafPort, sets the origin to {0 0}, resets the port’s pen, text and color information, sets the clip region to an “infinite” rectangle, and then calls BeginUpdate. All of the window’s port information is saved in WindowState.
_________________________________________________
 
sc-click-witem *349*
Input types: Window Item; EventRecord
Output types: boolean; Any
Description: This primitive is called when a mouse down event occurs in a window item to process the click. If CallMethod is TRUE, the click method of WindowItem should be called. If MethodInput is not NULL, pass it into the click method.
sc-click-witem performs an action appropriate to the type of window item. For example, a Button item is hilited while the user holds the mouse pointer over the Button. The primitive finishes when the user releases the mouse button.
CallMethod is TRUE if the mouse button is released over the Button. MethodInput will be NULL for those window items whose click method requires three inputs (<Window>, <Window Item> <EventRecord>). However, the click methods of Canvas, Check Box, Radio Set, Scroll List, and Pop-up Menu all require four inputs: MethodInput is passed in as the third input to the click methods of these window items (<EventRecord> being the fourth input).
_________________________________________________
 
sc-delete-item *349*
Input names: WindowItem | MenuItem
Input types: Window Item | Menu Item
Description: Deletes a window item from an active window, or deletes a menu item from an active menu.
_________________________________________________
 
sc-draw-witem *350*
Input types: Window Item
Description: Draws the window item. sc-draw-witem assumes the port has been set.
_________________________________________________
 
sc-end-drawing *350*
Input types: Canvas; ABlock
Description: Restores the graphical state of a canvas, and its owning window, after drawing. Used in conjunction with sc-begin-drawing.
_________________________________________________
 
sc-end-update *350*
Input types: Window; ABlock
Description: Restores the graphical state of a window after an update event. Used in conjunction with sc-begin-update.
sc-end-update calls the Mac Method EndUpdate.
_________________________________________________
 
sc-find-witem *351*
Input types: Window; Point; Boolean; Boolean
Output types: Window Item
Description: Finds the WindowItem which contains the Point. If Inactive is TRUE, inactive window items are included in the search. If Invisible is TRUE, invisible window items are included in the search. Note that sc-find-witem is different from the primitive find-item which searches for window items by name.
_________________________________________________
 
sc-get-wind *351*
Input types: NULL | Integer | WindowRecord@
Output types: NULL | Window
Description: Returns the instance of class Window associated with a window record, or NULL if NULL was input or if the window record does not belong to any of your application’s windows.
sc-get-wind is used to determine which window is the target of activate and update events.
_________________________________________________
 
sc-hilite-witem *351*
Input types: Window Item; Boolean
Description: If Hilite is TRUE, hilite the WindowItem. Otherwise, unhilite the WindowItem.
The effect of sc-hilite-witem is similar to that of setting WindowItem’s active? attribute. The difference is that sc-hilite-witem changes the window item temporarily. This primitive is used to dim window items when a window is deactivated, and re-hilite them when a window is activated.
_________________________________________________
 
sc-idle-edit *352*
Input types: EventRecord
Description: Performs idle functions necessary for Edit Text and Scroll Text window items.
If the selected item of the front window is not an Edit Text or Scroll Text item, sc-idle-edit does nothing. Otherwise, sc-idle-edit flashes the insertion point and changes the cursor to the I-beam while it’s over the selected item.
_________________________________________________
 
sc-insert-item *352*
Input names: Window | Menu; WindowItem | MenuItem; Position
Input types: Window| Menu; Window Item | Menu Item; Integer
Description: Inserts a window item into an active window, or a menu item into an active menu. Position will be index (1-based) into the item list of Window or Menu of the newly inserted item.
_________________________________________________
 
sc-key-button *352*
Input types: Window; EventRecord
Output types: Button
Description: If KeyEvent is Enter or Return, then sc-key-button hilites the window’s default button briefly and outputs the default button. If KeyEvent is not Enter or Return or the window has no default button, then Button will be NULL.
Description: When the selected item is an Edit Text or Scroll Text, the typed character is inserted into the item’s text.
The third input, KeyRepeat, is used to speed up text editing when running your program in the Interpreter. If KeyRepeat is greater than zero, sc-key-edit will intercept subsequent key events and handle them automatically. (A value of 200 gives good performance on the Macintosh Classic, probably the only machine on which it’s really necessary.) If KeyRepeat is omitted, every key event will pass through your application’s Notify method.
_________________________________________________
 
sc-key-list *353*
Input types: Scroll List; EventRecord
Output types: Boolean
Description: When the window’s selected item is a Scroll List, and the typed character is an up arrow or a down arrow, the list’s selection is moved up or down, respectively, and Processed is TRUE. Otherwise, Processed is FALSE.
_________________________________________________
 
sc-key-menu *354*
Input types: EventRecord
Output types: Integer; Integer
Description: Finds the menu and item associated with a Command key. If CommandKey is not a valid command key, MenuID will be zero. The MenuID corresponds to the Menu’s position in the Application’s menu list. The MenuItem ID corresponds to the Menu Item’s position in the Menu’s item list. For example, if MenuID is 3 and MenuItem ID is 5, the Command key belongs to the fifth item of the third menu.
_________________________________________________
 
sc-show-balloon *354*
Input types: Window; Point
Description: Shows a window item’s Balloon Help message if balloon help is on. This primitive is called when a null event is received.
_________________________________________________
 
sc-tab-witem *354*
Input names: WindowItem; KeyEvent | TabDirection
Input types: Window Item; EventRecord | Integer
Output types: Window Item
Description: Returns the next selectable window item in the window. If KeyEvent is not a Tab key, NextItem will be NULL. TabDirection can be 1 for forward or -1 for backward.
_________________________________________________
 
sc-zoom-wind *355*
Input types: Window; Integer
Description: Zooms a window. ZoomDirection can be the Mac Constants inZoomIn or inZoomOut. inZoomOut enlarges the window to fill the whole screen,while inZoomIn restores the window to its size before being zoomed out. This primitive would normally be called after the user has clicked in the zoom box of a window.