| addEventHandler |
(Object component, String name, Function handler) |
yoix.awt |
| |
Adds the function
handler
to
component
as
name.
Normally event handlers are added when the component is first defined, however
this built-in provides a way to add an event handler after a component is created.
If a function is already installed under the same
name,
it will be replaced by the supplied
handler.
Only if the supplied
name
corresponds to a valid event handler for the supplied
component
will
handler
be installed.
A non-zero
int
is returned when the event handler is successfully installed.
| |
| Example: |
The program,
import yoix.*.*;
Frame f = {
int visible = 1;
mouseExited(e) {
fprintf(stderr, "bye\n");
}
};
incoming(e) {
fprintf(stderr, "Mouse entered at (%f,%f)\n",
e.location.x, e.location.y);
}
outgoing(e) {
fprintf(stderr, "Mouse exited at (%f,%f)\n",
e.location.x, e.location.y);
}
addEventHandler(f, "mouseEntered", incoming);
addEventHandler(f, "mouseExited", outgoing);
pops up an empty frame and adds
mouseEntered
and
mouseExited
event handlers to it.
Notice that the original
mouseExited
event handler defined by the frame is replaced.
| | |
| Return: |
int
| | |
| See Also: |
removeEventHandler
|
|
Yoix is a registered trademark of AT&T Inc.
|