I have the following issues regarding ‘keyPressed.’ Does anyone know the reason? Are these issues on the DAW side or the JUCE side?
Code:
Following changes to the empty Plugin project generated by Projucer 7.0.7.
//==============================================================================
/**
*/
class NewProjectAudioProcessorEditor : public juce::AudioProcessorEditor
{
public:
NewProjectAudioProcessorEditor (NewProjectAudioProcessor&);
~NewProjectAudioProcessorEditor() override;
//==============================================================================
void paint (juce::Graphics&) override;
void resized() override;
// --- Added from here
virtual bool keyPressed(const juce::KeyPress& key) override {
if (key.getKeyCode() == 65) {
DBG("A received");
return true;
}
return false;
}
// ----- to here
private:
// This reference is provided as a quick way for your editor to
// access the processor object that created it.
NewProjectAudioProcessor& audioProcessor;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NewProjectAudioProcessorEditor)
};
Set setWantKeyboardFocus(true) in editor constructor.
NewProjectAudioProcessorEditor::NewProjectAudioProcessorEditor (NewProjectAudioProcessor& p)
: AudioProcessorEditor (&p), audioProcessor (p)
{
// Make sure that before the constructor has finished, you've set the
// editor's size to whatever you need it to be.
setWantsKeyboardFocus(true); // Added
setSize (400, 300);
}
Issue 1 Duplicated key press event in Ableton
- Environment : Windows 11 x64, Ableton Live 11.3.4
- Load vst3 plugin in DAW, in the plugin window press ‘a’ key once, then we receive 2 ‘a’ key events in the plugin
Issue 2 Key press is not consumed with “return true” in Studio One
- Environment : Windows 11 x64, Studio One 6.1.1
- Load vst3 plugin in DAW, in the plugin window press ‘a’ key once, then we receive 1 ‘a’ key events in the plugin However, DAW also receive a key event and the function associated with key ‘a’ is triggered( by defualt Studio One swtich the automation view by key ‘a’)