1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Add FocusOutline class for indicating Component keyboard focus

This commit is contained in:
ed 2021-12-20 09:40:42 +00:00 committed by Tom Poole
parent 0e24c9557e
commit 461192b355
14 changed files with 416 additions and 32 deletions

View file

@ -189,6 +189,24 @@ void Desktop::addFocusChangeListener (FocusChangeListener* l) { focusListen
void Desktop::removeFocusChangeListener (FocusChangeListener* l) { focusListeners.remove (l); }
void Desktop::triggerFocusCallback() { triggerAsyncUpdate(); }
void Desktop::updateFocusOutline()
{
if (auto* currentFocus = Component::getCurrentlyFocusedComponent())
{
if (currentFocus->hasFocusOutline())
{
focusOutline = currentFocus->getLookAndFeel().createFocusOutlineForComponent (*currentFocus);
if (focusOutline != nullptr)
focusOutline->setOwner (currentFocus);
return;
}
}
focusOutline = nullptr;
}
void Desktop::handleAsyncUpdate()
{
// The component may be deleted during this operation, but we'll use a SafePointer rather than a
@ -197,6 +215,8 @@ void Desktop::handleAsyncUpdate()
{
l.globalFocusChanged (currentFocus.get());
});
updateFocusOutline();
}
//==============================================================================