An attribute associated with certain button presses or certain key presses or other events can be assigned an event callback function, which will be invoked whenever an associated button or key is pressed or event takes place. All these functions, except as noted, can have from zero to three arguments, the basic syntax beingecfn{s;c;v}whereThe arguments always have these meanings, in this order, no matter how many (or few) are used in the definition of the function.
- s is static data (see below);
- c is a symbol naming the context of the object in which the cursor was positioned when the key or button press took place or for which the event occurred; and
- v is a symbol giving the unqualified name of this object.
The value of an attribute with callback is given as either the function name, say f, or a pair (f;), or a pair (f;s), where s is an array. The form (f;s) specifies the function and its static data s. Both f and (f;) are equivalent to (f;()), indicating that the static data is Null. Note that the first element of the value of the attribute is a function, not the name of a function; if you use the name f in specifying an attribute, change the definition of f, and want the callback to use the new definition, you must specify the attribute again.
The actions of some of these attributes depend on the row or cell that is currently selected; for example, the effect of the delete attribute is to delete the selected row. Whenever a function associated with one of these attributes is called because a key or button was pressed, some row or cell or trace in a displayed object must have been selected. Usually it is important to determine within the function which row or cell it is; the attributes row and col hold the row index and, when it is meaningful, the column index of the selected row or cell. The values of two other attributes are relevant here: the value of selected is the pair (row attribute, col attribute), and the value of selected field, which applies only to tables, is the nested array pair (row attribute; symbol holding the name of the selected field).
Some of these attributes have default behavior. For example, the default behavior of the delete attribute is to delete the selected row. These attributes can be assigned functional values to change the default behavior, or simply be assigned 0 to turn the default behavior off. If off, the default behavior can be turned back on by setting the value to 1. The default behavior can also be turned off with `false or `off in place of 0, or turned back on with `true or `on in place of 1.
When an attribute attr has a default behavior for the class to which an object obj is bound, that behavior can be invoked by s.call{`obj;`attr}. Thus, a callback function can be assigned to an attribute of an object that will, when called, make a decision whether or not to invoke the default action, to do some other work, or to do both or neither. s.call should work for all attributes with default callback behaviors; it will work for all attributes listed in 0Øs.EVENT_CALLBACKS.
When text is clipped in an Emacs or XTerm window, say by dragging the pointer over the area while the left button is depressed, the text is written in the primary selection buffer, and when text is pasted into an Emacs or XTerm window, it is retrieved from the primary selection buffer. A+ provides four attributes for using this buffer: primary, request, notify, and clear.To write in the primary selection buffer, give the primary attribute a character value. (Attempted settings with other types of data are quietly ignored; the value of primary remains unchanged.) Since there is only the one buffer, the value of the attribute changes for all objects.
To read the buffer, specify the request attribute for a bound object. If and when primary has been given a proper value, a notify event occurs and the buffer can be read by referencing the primary attribute.
If the buffer is overwritten by another process (not by an object in this A+ process), the A+ object, if any, whose specification of the primary attribute was overwritten will undergo a clear event. Dragging the pointer over text in an Emacs, Xterm, or FrameMaker window, for example, will cause a clear event. The text that is highlighted can then be retrieved through primary, but text that Emacs demarcated by bouncing the cursor back and forth cannot - but can, however, after you press the "0 to PRIMARY" button in an xcutsel window.
See the tutorial scripts, which are available under the "Tutorials" item on the "On-Line Documents" section of the home page. The entry "s.tutorials/data" gives an example, for the view class. It is an ASCII text file; use Emacs to access it.
doc@aplusdev.org | © Copyright 19952008 Morgan Stanley Dean Witter & Co. All rights reserved. |