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 › hiding other things with controlP5 hide function
Page Index Toggle Pages: 1
hiding other things with controlP5 hide function (Read 512 times)
hiding other things with controlP5 hide function
Oct 7th, 2008, 9:05am
 
i'm trying to hide a FPS indicator along with controlP5 controls, using controlP5's convenient built-in option/alt-h key command.  however i cannot get that key combo to be recognized.  i tried booleans to keep track of alt/option key on press and release and that didn't work.  also tried JS keyEvent.isAltDown() function as per this thread:
http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Syntax;action=display;num=1208144196

but that didn't work either.  it seems i can't override controlP5's handling of that particular key combo.   if i swap their order, i can see both 'h' and 'alt' keys are recognized, but not together.  how should i do it?

Code:

void keyPressed() {
if (key == 'h') {
println("h");
if (keyEvent.isAltDown()) {
println("alt/option + h : hide controls AND fps indicator");
fpsDisplay.hide();
}
}
}
Re: hiding other things with controlP5 hide functi
Reply #1 - Oct 7th, 2008, 1:26pm
 
this might help. instead of using
Code:

key=='h'

use the keyCode of h
Code:

keyCode==72


(alt has to be pressed before h.)
example:

Code:

boolean isVisible;

void setup() {
size(400,400);
}

void draw() {
background(0);
if(isVisible) {
fill(255,0,0);
rect(10,10,40,40);
}
}

void keyPressed() {
//println(keyCode);
// 72 is the keyCode for h
if(keyCode==72 && keyEvent.isAltDown()) {
isVisible = !isVisible;
}
}

Re: hiding other things with controlP5 hide functi
Reply #2 - Oct 10th, 2008, 7:17am
 
that worked, thanks.  curious, why would supplying keyCode work and key=='h' not work when key=='h' is recognized without controlP5 running?
Page Index Toggle Pages: 1