The FocusScope class holds the attributes of a focus scope: More...
#include <kanzi/core.ui/input/focus_scope.hpp>
Classes | |
class | FocusChain |
The FocusChain contains the snapshot of the focus chain of a focus scope. More... | |
Public Types | |
using | FocusChainSharedPtr = shared_ptr< FocusChain > |
The focus chain pointer type. More... | |
Public Member Functions | |
bool | canFocusEnter () const |
Returns whether the focus can enter the focus scope. More... | |
bool | canFocusLeave () const |
Returns whether the focus can leave the focus scope. More... | |
bool | canGetLastFocused () const |
Returns whether the focus scope node can be the last-focused node of its owning focus scope. More... | |
FocusChainNode | getFocus () const |
Returns the focus node of a focus scope. More... | |
FocusChainSharedPtr | getFocusChainSnapshot () |
Returns a snapshot of the focus chain of a focus scope. More... | |
FocusNavigationManipulatorSharedPtr | getFocusNavigationManipulator () const |
Returns the focus navigation manipulator of a focus scope. More... | |
ModalScope * | getModalScope () const |
Returns the modal scope that owns the focus scope. More... | |
virtual FocusScope * | getParent () const |
If a focus scope has a parent focus scope, returns the parent focus scope. More... | |
Node & | getRoot () const |
Returns the focus scope node. More... | |
virtual FocusManager::FocusScopeType | getType () const =0 |
Returns the type of the focus scope. More... | |
bool | isAttached () const |
Returns whether a focus scope node is attached. More... | |
bool | isFocusChainEmpty () const |
Returns whether the focus chain of a focus scope is empty. More... | |
bool | isFocused () const |
Returns the focused state of the focus scope. More... | |
virtual bool | isNodeInScope (const Node &node) const |
Returns whether a node is in a focus scope. More... | |
void | setFocusNavigationManipulator (FocusNavigationManipulatorSharedPtr newManipulator) |
Sets the focus navigation manipulator of the focus scope. More... | |
FocusChainNode | tryMoveFocusInScope (FocusManager::FocusChainDirection direction) |
Tries to set the focus to a node relative to the current focus node of the focus scope using the focus chain navigation. More... | |
FocusChainNode | tryRestoreScopeFocusedNode (FocusChainNode currentFocus, FocusManager::FocusReason reason, FocusManager::FocusChainDirection direction) |
Tries to restore the focus to the last-focused node of a focus scope. More... | |
Node::VisitorResult | visitFocusChain (FocusScopeVisitor &visitor) |
Visits the focus chain of the focus scope, and calls the visitor on each node. More... | |
Node::VisitorResult | visitFocusScope (FocusScopeVisitor &visitor) |
Visits the focusable nodes of the focus scope, including nested focus scope nodes. More... | |
virtual | ~FocusScope () |
Destructor. More... | |
The last-focused node | |
FocusChainIndex | getLastFocused () const |
Returns the focus chain index of the last-focused node of a focus scope. More... | |
void | setLastFocused (const FocusChainIndex &lastFocus) |
Sets the focus chain index of the last-focused node of the focus scope. More... | |
void | clearLastFocused () |
Clears the focus chain index of the last-focused node of a focus scope. More... | |
FocusChainNode | getLastFocusedNode () const |
Returns the last-focused node of a focus scope. More... | |
FocusChainNode | setLastFocusedNode (const Node &lastFocused) |
Sets the last-focused node of a focus scope. More... | |
void | clearLastFocusedNode () |
Set the Node::FocusedProperty value to false, and clears the last-focused node of a focus scope. More... | |
Static Public Member Functions | |
static FocusScopePtr | create (FocusManager::FocusScopeType type, Node &rootNode, FocusManager::ScopeStack &scopeStack) |
Creates an instance of a focus scope type, with the rootNode as the focus scope node. More... | |
Protected Types | |
enum | ScopeFlag { ScopeFlag::EnterFocusWithNavigationAllowed, ScopeFlag::LeaveFocusWithNavigationAllowed, ScopeFlag::CanGetLastFocusedNode, ScopeFlag::DisableAll, ScopeFlag::EnableAll } |
Defines the scope flags. More... | |
Protected Member Functions | |
void | focusNavigationHandler (FocusManager::MoveFocusMessageArguments &args) |
Navigates the focus in a scope. More... | |
FocusScope (Node &scopeNode, ScopeFlag flags) | |
Constructor. More... | |
void | invalidateFocusChain () override |
Overrides FocusScopeCore::invalidateFocusChain(). More... | |
void | joinScope (FocusScope &target) override |
Overrides FocusScopeCore::joinScope(). More... | |
void | notifyNodeAttached (Node &node) override |
Overrides FocusScopeCore::notifyNodeAttached(). More... | |
void | notifyNodeDetached (Node &node) override |
Overrides FocusScopeCore::notifyNodeDetached(). More... | |
void | notifyScopeTypeChange (FocusScope &oldScopeData) override |
Overrides FocusScopeCore::notifyScopeTypeChange(). More... | |
void | splitScope (FocusScope *target, FocusChainNode targetLastFocusedNode) override |
Overrides FocusScopeCore::splitScope(). More... | |
void | swapScopeData (FocusScope &other) |
Swaps the focus scope data of this scope with the focus scope data of the source scope. More... | |
Protected Attributes | |
const ScopeFlag | m_scopeFlags |
The scope flags. More... | |
The FocusScope class holds the attributes of a focus scope:
The root node of a focus scope is called the focus scope node. The FocusManager keeps track of all popup-type focus scopes that are attached to the node tree.
The Node class creates the focus scope information when you set the FocusManager::FocusScopeTypeProperty on a node. When you attach a popup-type focus scope node to the node tree, Kanzi registers the scope to the FocusManager. After Kanzi registers a popup-type focus scope to the FocusManager, you can activate the scope either by calling FocusManager::bringScopeToFront() or by dispatching the FocusManager::BringScopeToFrontMessage to the node or a child node of that popup-type scope.
The class provides the interface for FocusManager on testing focusable node candidates. When testing a node, or querying the focus scope for the next focus candidate, FocusScope checks that:
using kanzi::FocusScope::FocusChainSharedPtr = shared_ptr<FocusChain> |
The focus chain pointer type.
|
strongprotected |
Defines the scope flags.
|
virtual |
Destructor.
Constructor.
scopeNode | The focus scope node. |
flags | The focus scope flags. |
|
static |
Creates an instance of a focus scope type, with the rootNode as the focus scope node.
type | The focus scope type to create. |
rootNode | The focus scope node. |
scopeStack | The stack with the modal and popup scopes. |
bool kanzi::FocusScope::isAttached | ( | ) | const |
Returns whether a focus scope node is attached.
Node& kanzi::FocusScope::getRoot | ( | ) | const |
Returns the focus scope node.
|
virtual |
If a focus scope has a parent focus scope, returns the parent focus scope.
Reimplemented in kanzi::ModalScope.
ModalScope* kanzi::FocusScope::getModalScope | ( | ) | const |
Returns the modal scope that owns the focus scope.
|
pure virtual |
Returns the type of the focus scope.
Implemented in kanzi::PopupScope, kanzi::ModalScope, kanzi::FocusFence, and kanzi::FocusGroup.
|
virtual |
Returns whether a node is in a focus scope.
node | The node to check whether it is in the current focus scope. Skips nested popup and modal focus scopes. |
Reimplemented in kanzi::ModalScope.
FocusChainNode kanzi::FocusScope::getFocus | ( | ) | const |
Returns the focus node of a focus scope.
FocusChainIndex kanzi::FocusScope::getLastFocused | ( | ) | const |
Returns the focus chain index of the last-focused node of a focus scope.
void kanzi::FocusScope::setLastFocused | ( | const FocusChainIndex & | lastFocus | ) |
Sets the focus chain index of the last-focused node of the focus scope.
lastFocus | The focus chain index of the last-focused node. |
void kanzi::FocusScope::clearLastFocused | ( | ) |
Clears the focus chain index of the last-focused node of a focus scope.
FocusChainNode kanzi::FocusScope::getLastFocusedNode | ( | ) | const |
Returns the last-focused node of a focus scope.
FocusChainNode kanzi::FocusScope::setLastFocusedNode | ( | const Node & | lastFocused | ) |
Sets the last-focused node of a focus scope.
lastFocused | The node to set as the last-focused node of the focus scope. |
void kanzi::FocusScope::clearLastFocusedNode | ( | ) |
Set the Node::FocusedProperty value to false, and clears the last-focused node of a focus scope.
Node::VisitorResult kanzi::FocusScope::visitFocusScope | ( | FocusScopeVisitor & | visitor | ) |
Visits the focusable nodes of the focus scope, including nested focus scope nodes.
Generates the focus order offset for each node of the focus scope, and calls the visitor on each focusable node.
visitor | The focus scope visitor. |
Node::VisitorResult kanzi::FocusScope::visitFocusChain | ( | FocusScopeVisitor & | visitor | ) |
Visits the focus chain of the focus scope, and calls the visitor on each node.
visitor | The focus chain visitor. |
FocusChainSharedPtr kanzi::FocusScope::getFocusChainSnapshot | ( | ) |
Returns a snapshot of the focus chain of a focus scope.
bool kanzi::FocusScope::isFocusChainEmpty | ( | ) | const |
Returns whether the focus chain of a focus scope is empty.
The focus chain of a focus scope is empty if the focus scope does not contain any focusable nodes.
bool kanzi::FocusScope::isFocused | ( | ) | const |
Returns the focused state of the focus scope.
A focus scope is focused when the focus scope node has the Node::FocusedProperty value set to true. A focus scope node is set as focused when it holds the focus node of the application.
FocusNavigationManipulatorSharedPtr kanzi::FocusScope::getFocusNavigationManipulator | ( | ) | const |
Returns the focus navigation manipulator of a focus scope.
void kanzi::FocusScope::setFocusNavigationManipulator | ( | FocusNavigationManipulatorSharedPtr | newManipulator | ) |
Sets the focus navigation manipulator of the focus scope.
To remove the focus navigation manipulator from an attached node, pass a nullptr as argument.
newManipulator | The pointer to the focus navigation manipulator to set. To remove the focus manipulator from the focus scope, use nullptr. |
bool kanzi::FocusScope::canFocusEnter | ( | ) | const |
Returns whether the focus can enter the focus scope.
bool kanzi::FocusScope::canFocusLeave | ( | ) | const |
Returns whether the focus can leave the focus scope.
bool kanzi::FocusScope::canGetLastFocused | ( | ) | const |
Returns whether the focus scope node can be the last-focused node of its owning focus scope.
FocusChainNode kanzi::FocusScope::tryRestoreScopeFocusedNode | ( | FocusChainNode | currentFocus, |
FocusManager::FocusReason | reason, | ||
FocusManager::FocusChainDirection | direction | ||
) |
Tries to restore the focus to the last-focused node of a focus scope.
If the focus scope has no last-focused node, sets the focus to the first or last focusable node of the focus scope.
currentFocus | The node from which to remove the focus. |
reason | The reason to move the focus. |
direction | The direction based on which Kanzi moves the focus to the first or last focusable node of the focus chain. |
FocusChainNode kanzi::FocusScope::tryMoveFocusInScope | ( | FocusManager::FocusChainDirection | direction | ) |
Tries to set the focus to a node relative to the current focus node of the focus scope using the focus chain navigation.
The method takes the next focus candidate from the focus chain of the focus scope and its nested focus scopes in the given direction.
If the focus scope has no last-focused node set, the method sets the focus to:
The method fails if the focus scope has no focusable descendant node.
direction | The direction in which to query for the next focusable node. |
|
overrideprotected |
Overrides FocusScopeCore::invalidateFocusChain().
|
overrideprotected |
Overrides FocusScopeCore::splitScope().
|
overrideprotected |
Overrides FocusScopeCore::joinScope().
|
overrideprotected |
Overrides FocusScopeCore::notifyScopeTypeChange().
|
overrideprotected |
Overrides FocusScopeCore::notifyNodeAttached().
|
overrideprotected |
Overrides FocusScopeCore::notifyNodeDetached().
|
protected |
Swaps the focus scope data of this scope with the focus scope data of the source scope.
other | The focus scope with which the scope data is to switch. |
|
protected |
Navigates the focus in a scope.
args | The navigation message arguments received from the FocusNavigationManipulator. |
|
protected |
The scope flags.