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:
parent
0e24c9557e
commit
461192b355
14 changed files with 416 additions and 32 deletions
|
|
@ -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();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue