Share via


Managing the Focus

For a Windows Media Center page to process input from the remote in a meaningful way, certain elements on the page must be able to receive the focus. The focus enables the user to target elements on the page one at a time for selection (by pressing the OK button on the remote), for text input, for scrolling, or for other interactions available from the remote. The page must always provide a distinct visual highlight to indicate which item has the focus. The focus must always be on exactly one element at a time, and it must move in a logical way from one focusable item to the next when the user presses the Up, Down, Left, or Right arrow buttons.

Managing the focus involves the following main tasks:

  • Keeping track of where the focus is at all times.
  • Moving the focus correctly and logically in response to user input.
  • Highlighting the focus so the user can tell where it is.

Windows Media Center Presentation Layer Applications

For information about managing the focus in Windows Media Center Presentation Layer, see Working with Input Handlers in MCML.

Hosted HTML Applications

When you write script to establish how the focus moves around an HTML page, it is convenient to employ the browser's built-in focus features. The browser provides methods, properties, and events for controlling the focus from script. It automatically removes the focus from one item when you set the focus to a different item, and it automatically scrolls an item into view when the item gets the focus. The following items from the DHTML object model are useful in managing the focus from script. For more information about these items, see HTML and Dynamic HTML at the Microsoft Web site.

Item Description
activeElement property Retrieves the object that has the focus.
blur method Causes an object to lose the focus.
focus method Causes an object to receive the focus.
hasfocus method Retrieves the value indicating whether the object currently has the focus.
hideFocus property Gets or sets the value indicating whether the object visibly indicates that it has focus. In some cases, the browser automatically provides a visible indication, such as a thin dotted line, to show that an item has focus. This indicator is too subtle to be useful on a Windows Media Center page; the hideFocus property can be used to hide it.
onblur event Raised when an element loses the focus.
onfocus event Raised when an element receives the focus.

See Also