Unexpected behavior of 'addshortcut' function on return key

Hi,

I am trying to capture return key event on the on a juce Button within a component. I have used the function addShortCut and passed KeyPress::returnkey within. The problem is when i press enter key on the component, the application loads previous components for a brief period of time and then comes back to the component on which enter key was pressed.

It might have been the case that some of the listeners of previous components may have got automatically invoked. To rule out this possibility, i tried removing all the listeners of the other components and also tried using the method setKeyboardFocus(false) on other components (so that the focus wont go there in any case), but the problem persisted. I also tried to delete the previous components, but surprisingly, they were somehow still loaded for a brief time when i press enter.

I also tried using getKeyPressed instead of addshortcut method and also adding keylistener manually. But with no luck.

CAn somebody help?

Sorry, I don’t understand what you mean by “the application loads previous components”??

if it’s ‘loading old components’ or something, that’s not likely to be a juce problem, as juce doesn’t load any components for you - your program does. i imagine it’s likely that some part of your code is getting called (if you’ve deleted components, they’re gonna be created somewhere, so maybe that part’s getting re-called? unless it’s a painting issue