Modifier keys with a mouse click


I know that this a very particular case and only a few people may have reproduce this ill-behaviour… but…

I’m programming a “ctrl” based selection of some elements. I’m using the virtual MouseDown() and modifierKeysChanged() to do it. However, let’s suppose that the user presses de Ctrl button, starts selecting elements, clicks on another desktop window (without releasing the Ctrl button) and then releases the Ctrl button out of the JUCE app. When the user comes back to the JUCE application, the latter remembers that the Ctrl button is pressed and it behaves as it was pressed. This is weird and I don’t know how to get around it. I tried getCurrentModifiersRealtime () inside the MouseDown() method but “it doesn’t work” (I don’t get how it works…). I tried overriding the minimizeChanged() and the focusGained() methods of the component but this I guess that because this is not a desktop component (it’s a subcomponent of it) nothing really works either.

Any ideas out there? Is JUCE doing the right thing?


I’m surprised it doesn’t refresh the modifiers there… What platform are you on?


oh, no - don’t use a callback to get the modifier key state - the modifiers to use are supplied for you in the mouse event structure! The callback can’t get triggered unless the app has keyboard focus when the key changes.