Loading...
Searching...
No Matches
juce::FocusTraverser Class Reference

## 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

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

- juce_gui_basics/components/juce_FocusTraverser.h

Inheritance diagram for juce::FocusTraverser:

## Public Types

enum class | SkipDisabledComponents { no , yes }
| Controls whether the FocusTraverser will allow navigation to disabled components. More...

## Public Member Functions

| FocusTraverser ()=default
| Creates a FocusTraverser that will not skip disabled components.
| FocusTraverser (SkipDisabledComponents skipDisabledComponents)
| Creates a FocusTraverser.
| ~FocusTraverser () override=default
| Destructor.
Component * | getDefaultComponent (Component *parentComponent) override
| Returns the component that should receive focus by default within the given parent component.
Component * | getNextComponent (Component *current) override
| Returns the component that should be given focus after the specified one when moving "forwards".
Component * | getPreviousComponent (Component *current) override
| Returns the component that should be given focus after the specified one when moving "backwards".
std::vector< Component * > | getAllComponents (Component *parentComponent) override
| Returns all of the components that can receive focus within the given parent component in traversal order.
Public Member Functions inherited from juce::ComponentTraverser
virtual | ~ComponentTraverser ()=default
| Destructor.

## Member Enums

## SkipDisabledComponents

enum class juce::FocusTraverser::SkipDisabledComponents

strong

Controls whether the FocusTraverser will allow navigation to disabled components.

Enumerator
no | Disabled components can receive focus.
yes | Disabled components can't receive focus.

## Constructors and Destructors

## FocusTraverser() [1/2]

juce::FocusTraverser::FocusTraverser | ( |  | ) |

default

Creates a FocusTraverser that will not skip disabled components.

## FocusTraverser() [2/2]

juce::FocusTraverser::FocusTraverser | ( | SkipDisabledComponents | skipDisabledComponents | ) |

explicit

Creates a FocusTraverser.

Parameters

  skipDisabledComponents | If set to SkipDisabledComponents::yes, the traverser will ignore disabled components. This makes such components non-discoverable using screen readers.

## ~FocusTraverser()

juce::FocusTraverser::~FocusTraverser | ( |  | ) |

override default

Destructor.

## Member Functions

## getDefaultComponent()

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

override virtual

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 juce::ComponentTraverser.

## getNextComponent()

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

override virtual

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 juce::ComponentTraverser.

## getPreviousComponent()

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

override virtual

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 juce::ComponentTraverser.

## getAllComponents()

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

override virtual

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 juce::ComponentTraverser.

References no.

### Purchase

Get JUCE

### Discover

What's New in JUCE Features

### Learn

Documentaion Tutorials Made with JUCE Resources

### Support

JUCE Forum Newsletter Archive

### About

Contact Us JUCE Legal JUCE Licensing FAQ

### Events

Audio Developer Conference
© Raw Material Software Limited