Is there any way to detect if Caps Lock is on/off?
Also it’s on/off state should not affect the Shift key’s state.
you can use toLowerCase on any juce::String to transform it into a state where caps doesn’t matter
Windows:
bool capsLockDown()
{
if ((GetKeyState (VK_CAPITAL) & 0x0001) != 0)
return true;
return false;
}
macOS:
[NSEvent addLocalMonitorForEventsMatchingMask:NSEventMaskKeyDown | NSEventMaskKeyUp handler: ^NSEvent* (NSEvent* ev)
{
capsLock = ev.modifierFlags & NSEventModifierFlagCapsLock;
return ev;
}];
Is that macOS version Objective C? How do I integrate it into standard C++ JUCE code?
Yes, if you add a .mm file your project it is Objective-C++ and you can mix C++ and Objective-C in one file.
Make the header pure C++ and only use Objective-C in the implementation.
I think I have this in a juce module, where I have an .mm file that just includes the .cpp file, then on macOS I can use Objective-C and I ifdef it out on Windows.
Interestingly when searching the doxygen I found capsLock is queried in the UnityWrapper
I wonder how it ended up there, surely only Unity keyboards have caps lock
I have zero experience with ObjectiveC. Let’s see how it goes.