lz.FocusService
Handles keyboard focus.

JavaScript: lz.FocusService
extends lz.Eventable »

lz.Focus is the single instance of the class lz.FocusService.

This service manages the keyboard focus. At any time, at most one view has the keyboard focus. This is the view that receives key events when a key is pressed.

See The Software Developer's Guide for a discussion of keyboard focus.

Note that the view.getNextSelection() and view.getPrevSelection() methods can be overridden to change the tab order

Attributes

Name (CSS property) Type (tag) Type (js) Default Category
focuswithkey   Boolean   readonly
  This attribute is set to true when the focus has moved because the user has hit the next or prev focus key (usually 'tab' and 'shift-tab'.) If the focus moves due to mouse-click the value is set to false. If the focus moves through programmatic control, the value is unchanged from its last value.
lastfocus   lz.view   readonly
  A reference to the last view that held the focus

Class Attributes

Name (CSS property) Type (tag) Type (js) Default Category
LzFocus   lz.FocusService   readonly
  The focus service. Also available as the global lz.Focus.

Methods

clearFocus()
lz.FocusService.clearFocus();
Remove the focus from the currently focused view (if there is one). An 'onblur' event is first sent to the view.

getFocus()
lz.FocusService.getFocus();
Get the currently focused view.
Returns Type Description
  lz.view The view that has the focus, or null if none does.

getNext()
lz.FocusService.getNext(focusview : lz.view);
Returns the next focusable view.
Parameter Name Type Description
focusview lz.view optional starting view. By default focusview is the current focus.
Returns Type Description
  lz.view The view that would be the next focus.

getPrev()
lz.FocusService.getPrev(focusview : lz.view);
Returns the previous focusable view.
Parameter Name Type Description
focusview lz.view optional starting view. By default focusview is the current focus.
Returns Type Description
  lz.view The view that would be the focus if you shift tabbed

next()
lz.FocusService.next();
Move the focus to the next focusable view.

prev()
lz.FocusService.prev();
Move the focus to the previous focusable view.

setFocus()
lz.FocusService.setFocus(newsel : lz.view, fwkey);
Set the focus to the given view. If this is not the currently focused view, an onblur event is sent to the currently focused view, and an onfocus event is sent to the new view. When setFocus is called as the result of an onblur or onfocus event, all the delegates registered for the event run before the next setFocus call is made. While it is not an error for multiple responders to call setFocus as the result of the same onfocus or onblur event, only one of the calls will be executed. The state of the view may be unknown during the blur/focus process. When a view loses focus, its blurring variable is set to true during the process.
Parameter Name Type Description
newsel lz.view The view to focus or null to clear focus
fwkey    

Methods inherited from lz.Eventable

destroy, setAttribute

Events

Name Description
onescapefocus Sent when the last focusable object has been reached.
onfocus Sent when the focus changes, with the argument being the view that was just focused. If nothing is focused, this event is sent with null.

Events inherited from lz.Eventable

ondestroy