XUL:Focus Behaviour

Revision as of 16:16, 22 February 2006 by Enn (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The following is how Mozilla determines what elements can be focused and which can not:

  • elements that are hidden (display: none) cannot be focused
  • elements that have the CSS visibility property set to collapse or hidden are not focusable.
  • an HTML element in an editor is not focusable
  • an HTML element cannot be focused if it has a disabled attribute.
  • an XML element cannot be focused unless it has a link/xlink.
  • a XUL element that implements nsIDOMXULControlElement cannot be focused if its disabled property is true.
  • otherwise the focusability of an element is determined by the -moz-user-focus property. If it is set to 'ignore' or 'none, the element cannot be focused. Other values allow focus.
  • the value of -moz-user-focus is overriden for HTML elements if they have a tabindex attribute
  • the value of -moz-user-focus is overriden for an enabled XUL element that implements nsIDOMXULControlElement if its tabIndex property returns a value greater or equal to zero.
  • you can focus a scrollable HTML element -- one with overflow set to 'scroll' or 'auto' -- if you change the focus with the tab key, but not by using the mouse.

Some HTML elements such as form elements have additional focus rules.

On the Mac, there's a system setting "Full Keyboard Access", which can be used to toggle between this model and a model where only listboxes, trees and textboxes can be focused.

The following XUL elements implement nsIDOMXULControlElement:

button, caption, checkbox, colorpicker, description, label, listbox, listitem, menu, menuitem, menulist, radio, radiogroup, richlistbox, richlistitem, tab, tabs, textbox, tree

The following XUL elements have -moz-user-focus set to normal:

browser, editor, iframe