|
MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
|
| bool MayaFlux::Portal::Forma::Context::set_focus | ( | uint32_t | id | ) |
Give keyboard focus to an element from code.
Runs the same focus-lost and focus-gained callbacks, and the WINDOW_FOCUS_LOST and WINDOW_FOCUS_GAINED subscriptions, as a press that moves focus. Key and text callbacks then reach the element, so a menu driven by keys or a controller works without the pointer.
Refused for an id the Layer does not hold, or whose element is hidden or not interactive. Focusing the element that already has focus does nothing and returns true. Call it on the graphics thread, where the other callbacks run.
A focus callback or subscriber may itself move focus, here or on a press, and the later move wins. An element whose focus-gained callback has run is always told when it loses focus, by its callback and its subscriptions. Its WINDOW_FOCUS_GAINED subscriptions are skipped if focus moved on before they were reached.
| id | Element to focus. |
id has focus when the call returns: false if it was refused, or if a focus callback moved focus elsewhere. Definition at line 277 of file Context.cpp.
References MayaFlux::Portal::Forma::Element::interactive, m_focused, m_layer, move_focus(), and MayaFlux::Portal::Forma::Element::visible.
Referenced by MayaFlux::Portal::Forma::internal::ask_in(), and operator=().