MovieClip.tabEnabled Property

ActionScript for Flash MX: The Definitive Guide, 2nd Edition
By Colin Moock
Chapter 18.  ActionScript Language Reference
MovieClip.tabEnabled Property Flash 6

includes or excludes the movie clip from the current tab order read/write
mc.tabEnabled

Description

The Boolean tabEnabled property governs whether mc is part of the tab order for the text fields, movie clips, and buttons currently on screen. The tab order is the sequence in which objects are focused when the Tab key is pressed in a movie. See TextField.tabEnabled for complete details.

For movie clips, the tabEnabled property can:

  • Exclude a movie clip with a defined tabIndex from the custom tab order

  • Exclude any clip with button event(s) from the automatic tab order

  • Include a movie clip in the automatic tab order (the automatic tab order does not, by default, include clips without button events)

By default, tabEnabled is undefined and mc is excluded from the automatic tab order unless it defines at least one button handler (onPress( ), onRelease( ), etc.), in which case it is included in the automatic tab order.

A movie clip that does not define button handlers typically is added to the automatic or custom tab order when it is an interface element that is keyboard accessible. For example, a listbox movie clip should be focusable via the Tab key and controllable via the arrow keys, so it should have a tabEnabled property of true.

By default, when a movie clip has focus, Flash surrounds it with a yellow rectangle. To supply a custom highlight state, we should first turn the yellow rectangle off by setting MovieClip._focusrect to false, and then either create the highlight state inside the clip's onSetFocus( ) handler, or define _up and _over frames in the clip that correspond to the unfocused and focused states, respectively. (Flash automatically displays those special frames when the clip loses and gains focus.)

To allow a movie clip to be focused programmatically via Selection.setFocus( ), we must set its focusEnabled property to true. Note that the tabEnabled property applies to the Tab key only, while the focusEnabled property applies to Selection.setFocus( ) only. For many interface widgets, it is appropriate to disable automatic tabbing for all of the clip's children (the nested clips, buttons, and text fields it contains). We can do this conveniently by setting the tabChildren property to false. Disabling automatic child tabbing allows us to dictate the keyboard behavior of a clip explicitly, without worrying about interference from any subordinate interface elements it may contain.

In general, to enable focus for a movie clip interface widget we combine the following property settings:

// Disable automatic yellow focus rectangle theClip_mc._focusrect = false; // Allow the clip to be focused by the Tab key theClip_mc.tabEnabled = true; // Allow the clip to be focused by Selection.setFocus() theClip_mc.focusEnabled = true; // Prevent automatic tabbing to clips, text fields, and buttons inside the clip theClip_mc.tabChildren = false;

Note that when a clip's tabEnabled is false, any text fields, buttons, or movie clips it contains may still have tabbing enabled. To disable tabbing for a clip and all its contained objects, set both tabEnabled and tabChildren to false.

Movie clips that behave as buttons (i.e., that define button event handlers) normally have tabEnabled set to false when they are disabled (when the enabled property is set to false) or when they are accessible only to mouse input, such as in games that use transparent buttons to detect mouse hit regions.

Usage

The Tab key does not work reliably in Test Movie mode unless Control figs/u2192.gif Disable Keyboard Shortcuts is enabled. Be sure to test keyboard behavior in the Standalone Player, if applicable, and in the Flash Player for all targeted web browsers.

See Also

MovieClip.enabled, MovieClip.focusEnabled, MovieClip.onSetFocus( ), MovieClip.tabChildren, MovieClip.tabIndex, Selection.setFocus( ), TextField.tabEnabled



    ActionScript for Flash MX. The Definitive Guide
    ActionScript for Flash MX: The Definitive Guide, Second Edition
    ISBN: 059600396X
    EAN: 2147483647
    Year: 2002
    Pages: 780
    Authors: Colin Moock

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net