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 & HelpSyntax Questions › wrong way keystroke
Page Index Toggle Pages: 1
wrong way? keystroke (Read 249 times)
wrong way? keystroke
Apr 30th, 2008, 12:10am
 
hi!

i´m tutoring in a cad programm and want to build a little helper for me. its just a little visual thing showing which mouse button is pressed, and if shift, alt or control is pressed too because this is a question i hear about thousand  times....

is this the wright way?

first thing and easy: a rect is displayed according to the mouse button;

next i just wanna write "shift" if shift is pressed, and nothing if it is released (and so on with alt and control), but i don´t get it. how could i do that?

PFont blender;

void setup()
{
 size(200, 300);
 background(100);


}


int a;
int b;
int control;
int alt;
String s;
int c;


void draw()
{
 if (mousePressed && (mouseButton == LEFT)) {
   a = 255;
   b = 20;
   }
     else if (mousePressed && (mouseButton == CENTER)) {
       a = 255;
       b = 75;
       }
         else if (mousePressed && (mouseButton == RIGHT)) {
           a = 255;
           b = 130;
           }
     else
       { a = 0; }

         noStroke();
         rect (b,25,40,50);
         fill (a);

}

void keyPressed ()

{
   

              if (keyPressed && (keyCode == SHIFT))
              { s = " # pressed shift # "; c = 255; }
             
/*                 else if (keyCode == CONTROL) {
                   control = 255;
                     }
                     else if (keyCode == ALT) {
                       alt = 255;
                        }
*/                
                          else
                          { s = " #nothing# "; c = 0; }
                 
/*                  blender = loadFont("BlenderBook24.vlw");
                 textFont (blender, 48);
                 text (s, 10, 200 );
                 fill (c);
*/

                 print (s);



thx

Page Index Toggle Pages: 1