From ProtoScript
Contents |
[edit] YUI:Focus Behavior
Adds a focus event to the current behavior or callback. Focus means the element or elements has gained focus (e.g., tab or click into a text field). Opposite of the Blur Behavior.
[edit] Example
$proto('input#firstName', {
Focus: {
onFocus: {
Fade: {
opacity: {to: 0.5}
}
}
},
});
When the user tabs into or clicks in the input field with ID='firstName', fade the input field to half transparent.
[edit] Attributes
| Name | Description | Default | Valid Values | Example |
|---|---|---|---|---|
| target | Selected element or elements to attach a focus event to. See Element Scope | Inherited from parent behavior. If no value supplied, use the last targeted element. If value is supplied, use the element(s) selected by the target instead. | String value denoting an interface element. | target:'#avatar' |
| modifier | Name of modifier key that must be pressed for the event to fire | 'shift', 'alt', 'ctrl' | no value | modifier: 'alt' |
| delay | Amount of time (in seconds) to delay before firing the callback. | No delay is set. | number | delay: 0.5 |
[edit] Callbacks
| Name | Description |
|---|---|
| onFocus | The callback corresponding to the Focus behavior. Fired when the target gains focus. |
[edit] Demos
See Focus Demo
