i’m a bit confused by the keylistener.
i have my main component, a window. it contains a second component, a circle. i want my circle to “do” something, when a key is pressed.
so i made the main component a keyListener, and added the function
i set that and checked, that my main component has keyboard focus.
but it seems that the KeyPressed function never gets called. who is supposed to call it?
is there maybe an easy example of the function of keylistener in the juce examples?
It should be pretty simple, I am assuming that “x” class is the one interested in receiving keypress callback when keys are pressed and that it is the component being displayed.
Derive x from “KeyListener” and implement “bool keyPressed(const juce::KeyPress &key,juce::Component * originatingComponent);”
[quote=“vishvesh”]It should be pretty simple, I am assuming that “x” class is the one interested in receiving keypress callback when keys are pressed and that it is the component being displayed.
Derive x from “KeyListener” and implement “bool keyPressed(const juce::KeyPress &key,juce::Component * originatingComponent);”
that should solve the problem.[/quote]
hi! yes this did work out. i don’t know why i have overseen this way (which seems to be the most intuitive way now too) so thank you for pointing my nose to the right direction!
[quote=“haesslich”]
hi! yes this did work out. i don’t know why i have overseen this way (which seems to be the most intuitive way now too) so thank you for pointing my nose to the right direction![/quote]