How to intercept key strokes at application level?


#1

Does anybody know how to intercept key strokes and mouse activities at application level? Thanks in advance.


#2

That’s a very general question. What exactly are you trying to do? Usually there are much better ways of doing things than using global mechanisms.


#3

Hi Ju!

Currently I play with JUCE and I try to port my existing application to it. I try to transfer as much functionality as possible.
The problem is I want to intercept all F1…F12 system key strokes and the num pad keys globally no matter what component has the focus currently. Moreover, I need to check whether the Alt/Ctrl/Shift/Home/End/Del keys are pressed too. Moreover, I need to implement mouse gestures and I do not know how to intercept mouse moves over the component which swarms with child components that cover it entirely.


#4

Well there are lots of ways - you could catch key events in the top level component, or set up global application commands which are linked to those keystrokes.

For the mouse you could use addMouseListener to make the top-level component catch all mouse events in subcomponents.


#5

Thank you Ju!
Did I tell you that you are genius? :smiley:


#6

[quote=“Ptomaine”]Thank you Ju!
Did I tell you that you are genius? :D[/quote]

Ta. (though I think I prefer “Jules” to “Ju” if you don’t mind the extra typing…)


#7

Sure Jules!

Sorry for Ju. :oops: Just haven’t known how to abbreviate Julian properly. Russians are strange always, you know :smiley: . I’m not afraid of extra typing that’s why I’m the programmer 8) :lol:. I mean the real programmers mustn’t be lazy, you know :wink:.

BTW, my name is Arlen. :roll:

:idea:
You may call me Ar if you want to retaliate for. :smiley:


#8

:lol:


#9

Ju sounds like a japanese cartoon hero. (Possibly a teen girl who goes to boarding school but is a ninja by night)


#10

That came out of left field!


#11