JUCE  v5.4.1-191-g0ab5e696f
JUCE API
Looking for a senior C++ dev?
I'm looking for work. Hire me!
juce::KeyboardFocusTraverser Class Reference

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

#include <juce_KeyboardFocusTraverser.h>

Public Member Functions

 KeyboardFocusTraverser ()
 
virtual ~KeyboardFocusTraverser ()
 Destructor. More...
 
virtual ComponentgetDefaultComponent (Component *parentComponent)
 Returns the component that should receive focus be default within the given parent component. More...
 
virtual ComponentgetNextComponent (Component *current)
 Returns the component that should be given focus after the specified one when moving "forwards". More...
 
virtual ComponentgetPreviousComponent (Component *current)
 Returns the component that should be given focus after the specified one when moving "backwards". More...
 

Detailed Description

Controls the order in which focus moves between components.

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

  • 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.
  • any unspecified components are traversed in a left-to-right, then top-to-bottom order.

If you need traversal in a more customised way, you can create a subclass of KeyboardFocusTraverser that uses your own algorithm, and use Component::createFocusTraverser() to create it.

See also
Component::setExplicitFocusOrder, Component::createFocusTraverser

{GUI}

Constructor & Destructor Documentation

◆ KeyboardFocusTraverser()

juce::KeyboardFocusTraverser::KeyboardFocusTraverser ( )

◆ ~KeyboardFocusTraverser()

virtual juce::KeyboardFocusTraverser::~KeyboardFocusTraverser ( )
virtual

Destructor.

Member Function Documentation

◆ getDefaultComponent()

virtual Component* juce::KeyboardFocusTraverser::getDefaultComponent ( Component parentComponent)
virtual

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

The default implementation will just return the foremost child component that wants focus.

This may return nullptr if there's no suitable candidate.

◆ getNextComponent()

virtual Component* juce::KeyboardFocusTraverser::getNextComponent ( Component current)
virtual

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

The default implementation will return the next component which is to the right of or below this one.

This may return nullptr if there's no suitable candidate.

◆ getPreviousComponent()

virtual Component* juce::KeyboardFocusTraverser::getPreviousComponent ( Component current)
virtual

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

The default implementation will return the next component which is to the left of or above this one.

This may return nullptr if there's no suitable candidate.


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