We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOther Libraries › how to extend controlP5 keyboard Hide command
Page Index Toggle Pages: 1
how to extend controlP5 keyboard Hide command? (Read 463 times)
how to extend controlP5 keyboard Hide command?
Jan 3rd, 2009, 2:54am
 
looking for example code of extending controlP5's key listeners.  i just want to add noCursor() to the built-in ALT+h command to hide/show controllers.
Re: how to extend controlP5 keyboard Hide command?
Reply #1 - Jan 4th, 2009, 6:03am
 
extending controlP5's key listener is currently not possible, but you can add this to your sketch:

Code:

void keyPressed() {
if(keyCode==72 &&
keyEvent.getModifiers()==(KeyEvent.SHIFT_MASK | KeyEvent.ALT_MASK)) {
if(controlP5.window(this).isVisible()) {
cursor();
} else {
noCursor();
}
println("SHIFT-ALT-h has been pressed, do something.");
}
}


Re: how to extend controlP5 keyboard Hide command?
Reply #2 - Jan 14th, 2009, 6:02am
 
thanks, just got around to trying this.  it works. but it also works without the SHIFT mask, which is better since it conforms to known controlP5 behavior, and of course requires less key presses.  why did you put that in?  is there some scenario where it would be necessary?
Re: how to extend controlP5 keyboard Hide command?
Reply #3 - Jan 14th, 2009, 1:02pm
 
works perfectly fine without SHIFT and the SHIFT_MASK, code nippet should only say:

Code:

void keyPressed() {  
 if(keyCode==72 &&  
    keyEvent.getModifiers()==(KeyEvent.ALT_MASK)) {
   if(controlP5.window(this).isVisible()) {
cursor();
   } else {
noCursor();
   }
   println("ALT-h has been pressed, do something.");
 }
Page Index Toggle Pages: 1