I’ve been having a lot of issues with keyfocus I was wondering if there was a way to add a function to the main event loop so all my components can share keyfocus. I’ve looked into:
void* MessageManager::callFunctionOnMessageThread ( MessageCallbackFunction * callback,
void * userData
,but I’m not sure if that’s the correct function to be trying to implement something like this. I just need all my components to share keyfocus because I’m trying to implement something like the midi keyboard component in a vst host I’m working on, and I don’t want the user to have to click on the components view every time to play notes through their computer keyboard or have it lose focus when clicking somewhere else, and have to make calls to grabkeyfocus because that locks up text edit parameters in vst’s on windows…
I think you just want to call
on you sliders. There is a slight caveat to this though - as they’re currently implemented the JUCE Sliders respond to key events (for example, if you hold down the alt key then you can move the slider with a much greater precision) so in this case key events will go to both your keyboard and all your sliders simultaneously. However, in practice, for this specific use case, you’ll probably be fine
Thanks tom but I’m trying to create a vst host not a vst. I was wondering if there was a way to bypass all the keyfocus for the separate components and views and just have one shared keyevent loop.
Oh, so you don’t have control over the elements which are taking keyfocus focus from your keyboard component? The nicest way of handling this is to use a similar method to the one I suggested - just block all the other components stealing the focus if possible.
Another approach would be to capture key presses in a parent component and manually dispatch them to the children.
Thanks tom. I will try that out, but the component I’m having issues with is the vst plugin window which is a private class that gets passed to audio processor editor. I’m not sure that overriding the components key event functions will have any effect unless I access the private vst plugin windows HWND or NSVIew. I don’t want to make a mess of the library I was hoping there would be a cleaner way.
I found a way for “shared key focus” between components on os x. Have not tested it fully .In the NSViewComponentPeer class there are two methods static keyUp and keyDown. This kind of achieves what I wanted just have to implement it correctly I suppose. Anyone know of a similar class for win32? Looks like the gui modules are not accessible though.