Skip to content

Commit 9d34786

Browse files
committed
Keyboard focus and selection should be technically accurate re: inspector
1 parent 65190b3 commit 9d34786

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

melatonin_inspector.h

+11-11
Original file line numberDiff line numberDiff line change
@@ -377,13 +377,13 @@ namespace melatonin
377377

378378
private:
379379
juce::SharedResourcePointer<InspectorSettings> settings;
380-
melatonin::InspectorLookAndFeel inspectorLookAndFeel;
381-
melatonin::InspectorComponent inspectorComponent;
380+
InspectorLookAndFeel inspectorLookAndFeel;
381+
InspectorComponent inspectorComponent;
382382
juce::Component::SafePointer<juce::Component> root;
383383
bool inspectorEnabled = false;
384-
melatonin::Overlay overlay;
385-
melatonin::FPSMeter fpsMeter;
386-
melatonin::OverlayMouseListener overlayMouseListener;
384+
Overlay overlay;
385+
FPSMeter fpsMeter;
386+
OverlayMouseListener overlayMouseListener;
387387
InspectorKeyCommands keyListener { *this };
388388
bool rootFollowsComponentUnderMouse = false;
389389

@@ -416,15 +416,15 @@ namespace melatonin
416416

417417
void globalFocusChanged (Component* focusedComponent) override
418418
{
419-
// nullptr focus events fire when focus is lost
419+
// ignore nullptr focus events, they are frequent and cause glitchiness
420420
if (focusedComponent == nullptr)
421421
return;
422422

423-
// we only want to respond to focus events related to the UI under inspection (root)
424-
// Unfortunately, we can't test to see if the focusedComponent is a child of root
425-
// because JUCE UI like list boxes or text editors sometimes technically have no parent :/
426-
if (focusedComponent != root && focusedComponent->getTopLevelComponent() != inspectorComponent.getTopLevelComponent())
427-
selectComponent (focusedComponent);
423+
// This gets sent all components, even subcomponents of the inspector
424+
// (which will result in the selection being cleared).
425+
// I tried filtering those out for cleaner UX,
426+
// but it caused glitchy incorrectness in focus selections
427+
selectComponent (focusedComponent);
428428
}
429429

430430
void timerCallback() override

0 commit comments

Comments
 (0)