Hi, I’ve added a public KeyListener to my components, to get it to compile I had to add four functions:
The first two are never called…
bool keyPressed(const KeyPress& key, Component* originatingComponent) override
{
ignoreUnused(originatingComponent);
DBG(String(key.getKeyCode())+", "+key.getTextCharacter());
return true;
}
bool keyStateChanged(bool isKeyDown, Component* originatingComponent) override
{
ignoreUnused(isKeyDown, originatingComponent);
return true;
}
bool keyPressed(const KeyPress& key) override
{
DBG(String(key.getKeyCode()) + ", " + key.getTextCharacter());
return true;
}
bool keyStateChanged(bool) override
{
return true;
}
If I delete the first two I get this error:
1>..\..\Source/Panel.h(295,7): warning : 'Panel::keyPressed' hides overloaded virtual function [-Woverloaded-virtual]
1>D:\Plug-ins\JUCE\modules\juce_gui_basics/keyboard/juce_KeyListener.h(66,18): note: hidden overloaded virtual function 'juce::KeyListener::keyPressed' declared here: different number of parameters (2 vs 1)
1>..\..\Source/Panel.h(300,7): warning : 'Panel::keyStateChanged' hides overloaded virtual function [-Woverloaded-virtual]
ins\JUCE\modules\juce_gui_basics/keyboard/juce_KeyListener.h(83,18): note: hidden overloaded virtual function 'juce::KeyListener::keyStateChanged' declared here: different number of parameters (2 vs 1)
And If I delete the second two I get this error:
…..\Source/Panel.h(282,7): warning : ‘Panel::keyPressed’ hides overloaded virtual function [-Woverloaded-virtual]
1>D:\Plug-ins\JUCE\modules\juce_gui_basics/components/juce_Component.h(1908,18): note: hidden overloaded virtual function ‘juce::Component::keyPressed’ declared here: different number of parameters (1 vs 2)
1>…..\Source/Panel.h(289,7): warning : ‘Panel::keyStateChanged’ hides overloaded virtual function [-Woverloaded-virtual]
1>D:\Plug-ins\JUCE\modules\juce_gui_basics/components/juce_Component.h(1932,18): note: hidden overloaded virtual function ‘juce::Component::keyStateChanged’ declared here: different number of parameters (1 vs 2)
Note the (2 vs 1) and (1 vs 2)
Can someone help, what is going on here? Why do I need to override four functions, when only two are ever called?
I apologise if it’s easy, but I don’t understand why.
I’m using the latest Juce master 8.0.3
Dave H.
