Luckily, there's a really straightforward to accomplish this - and it's all held in the event that triggered your method.
if ((event.getModifiers() & JSEvent.MODIFIER_SHIFT) != 0) {The operator is a bit operator - that's why you have to use this type of syntax - but since there are event constants (under Application -> JSEvent in the Solution Explorer) - it's easy to check for whatever key combination you want!
application.output("shift")
} else if ((event.getModifiers() & JSEvent.MODIFIER_ALT & JSEvent.MODIFIER_CTRL) != 0 ) {
appliction.output ("alt and ctrl");
}
You can also tell what type of action the user was doing (as well as any key combinations) - by using the event.getType() function. Here's an example:
if (event.getType() == JSEvent.ACTION) {There are other even type constants you can take advantage of including: action, datachanged, focuslost, focusgained, none (for unknown types), ondrag, ondragover, ondrop and rightclick.
application.output("user clicked");
} else if (event.getType() == JSEvent.RIGHTCLICK) {
application.output("user right clicked");
} else if (event.getType() == JSEvent.DOUBLECLICK) {
application.output("user double clicked");
}
No comments:
Post a Comment