
Button._parent Property
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
470
|
ActionScript Language Reference
When a button’s tabEnabled property is false, the button cannot be focused by the user
but can be focused programmatically with Selection.setFocus(). The following code regis-
ters a callback function that responds to onSetFocus():
// Assign the onSetFocus() callback using a function literal
next_btn.onSetFocus = function (oldFocus) {
trace(this + " now has focus. Old focus was " + oldFocus);
};
Notice that from the body of the callback, we can refer to next_btn using the this keyword.
To stop a callback from handling the onSetFocus() event, use the delete operator, as in:
// Make sure to omit the () operator after the function name!
delete next_btn.onSetFocus;
To detect attainment of focus via either the keyboard or mouse, use the onRollOver()
handler, which executes both when the mouse is over
theButton and when theButton gains
keyboard focus. To capture all focus events centrally, rather than for a single instance, use
Selection.onSetFocus().
To activate a keyboard-focused button, the user must press the Enter key or spacebar
(which has the same effect as clicking the button and causes the button’s onRelease()
handler to execute).
See Also
Button.onKillFocus(), Button.onRollOver(), MovieClip.onSetFocus(), Selection.onSetFocus( ...