JUCE: FocusTraverser Class Reference

JUCE

Public Member Functions | List of all members
FocusTraverser Class Reference
juce_gui_basics » components

Controls the order in which focus moves between components. More...

`#include <juce_FocusTraverser.h>`

Inheritance diagram for FocusTraverser:

## Public Member Functions
| ~FocusTraverser () override=default
| Destructor. More...
Component * | getDefaultComponent (Component *parentComponent) override
| Returns the component that should receive focus by default within the given parent component. More...
Component * | getNextComponent (Component *current) override
| Returns the component that should be given focus after the specified one when moving "forwards". More...
Component * | getPreviousComponent (Component *current) override
| Returns the component that should be given focus after the specified one when moving "backwards". More...
std::vector< Component * > | getAllComponents (Component *parentComponent) override
| Returns all of the components that can receive focus within the given parent component in traversal order. More...
Public Member Functions inherited from ComponentTraverser
virtual | ~ComponentTraverser ()=default
| Destructor. More...
virtual Component * | getDefaultComponent (Component *parentComponent)=0
| Returns the component that should be used as the traversal entry point within the given parent component. More...
virtual Component * | getNextComponent (Component *current)=0
| Returns the component that comes after the specified one when moving "forwards". More...
virtual Component * | getPreviousComponent (Component *current)=0
| Returns the component that comes after the specified one when moving "backwards". More...
virtual std::vector< Component * > | getAllComponents (Component *parentComponent)=0
| Returns all of the traversable components within the given parent component in traversal order. More...

## Detailed Description

Controls the order in which focus moves between components.

The algorithm used by this class to work out the order of traversal is as follows:

- Only visible and enabled components are considered focusable.
- If two components both have an explicit focus order specified then the one with the lowest number comes first (see the Component::setExplicitFocusOrder() method).
- Any component with an explicit focus order greater than 0 comes before ones that don't have an order specified.
- Components with their 'always on top' flag set come before those without.
- Any unspecified components are traversed in a left-to-right, then top-to-bottom order.

If you need focus traversal in a more customised way you can create a ComponentTraverser subclass that uses your own algorithm and return it from Component::createFocusTraverser().

See also
  ComponentTraverser, Component::createFocusTraverser

## Constructor & Destructor Documentation

## ◆ ~FocusTraverser()

FocusTraverser::~FocusTraverser | ( |  | ) |
| overridedefault

Destructor.

## Member Function Documentation

## ◆ getDefaultComponent()

Component * FocusTraverser::getDefaultComponent | ( | Component * | parentComponent | ) |
| overridevirtual

Returns the component that should receive focus by default within the given parent component.

The default implementation will just return the foremost visible and enabled child component, and will return nullptr if there is no suitable component.

Implements ComponentTraverser.

## ◆ getNextComponent()

Component * FocusTraverser::getNextComponent | ( | Component * | current | ) |
| overridevirtual

Returns the component that should be given focus after the specified one when moving "forwards".

The default implementation will return the next visible and enabled component which is to the right of or below this one, and will return nullptr if there is no suitable component.

Implements ComponentTraverser.

## ◆ getPreviousComponent()

Component * FocusTraverser::getPreviousComponent | ( | Component * | current | ) |
| overridevirtual

Returns the component that should be given focus after the specified one when moving "backwards".

The default implementation will return the previous visible and enabled component which is to the left of or above this one, and will return nullptr if there is no suitable component.

Implements ComponentTraverser.

## ◆ getAllComponents()

std::vector< Component * > FocusTraverser::getAllComponents | ( | Component * | parentComponent | ) |
| overridevirtual

Returns all of the components that can receive focus within the given parent component in traversal order.

The default implementation will return all visible and enabled child components.

Implements ComponentTraverser.

The documentation for this class was generated from the following file:

- juce_FocusTraverser.h