Confusion regarding ApplicationCommandManager and setFirstCommandTarget()

For reasons that aren’t relevant to this issue, I’m looking to prevent my program from recognizing keyboard shortcuts while the user is dragging a ScrollBar. I couldn’t find any in-library features for this, so I tried to implement my own solution with a derived ScrollBar class that calls a global ‘ScrollBarManager’ object’s ‘suppressCommands()’ and ‘unsuppressCommands()’ functions in the ScrollBar’s mouseDown() and mouseUp(), respectively. These functions are fairly straightforward (‘manager’ is a pointer to the MainComponent’s ApplicationCommandManager object, while ‘sinkhole’ is a unique_ptr for a dummy ApplicationCommandTarget object that doesn’t accept any commands and ‘mainTarget’ is a pointer to the MainComponent - both of these values are set in the class in its constructor):

void ScrollBarManager::suppressCommands() {
manager->setFirstCommandTarget(sinkhole.get());
}

void ScrollBarManager::unsuppressCommands() {
manager->setFirstCommandTarget(mainTarget);
}

While both functions appear to work (inspecting them in Visual Studio’s debugger seems to indicate that they’re passing the right pointers around), calling them from the ScrollBar’s mouse functions causes the ApplicationCommandManager to stop working entirely - it no longer calls its functions, nor does it receive or perform any commands. I tried making some simple changes to the functions (like using a reference for mainTarget or moving the functions into MainComponent via a Listener), but none of them had any effect on the outcome.

What confuses me is what happened when I tried to test setFirstCommandTarget() from MainComponent::resized() (this is after I moved the suppression functions into MainComponent):

void MainComponent::resized()
{
static int a = 0;
a++;
if (a % 20 < 10) {
DBG(“A”);
suppressCommands();
}
else {
DBG(“B”);
unsuppressCommands();
}
setBounds(0, 0, getWidth(), getHeight());
patternEditor->setBounds(getBounds());
}

This code worked perfectly, even though the only difference is the original source of the function call. As someone who’s still unfamiliar with JUCE’s architecture, I would love to understand this discrepancy and find a way to implement this feature properly. Don’t hesitate to let me know if you need any more information about the code.