Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

What's wrong with this 'if/if else' statement?

$
0
0

I am using the ControLP5 library to create a list box and each item in the list box has an assigned value (0.0, 1.0, 2.0, 3.0 etc).

As you can see in the if statement below, when the user clicks on an item with a certain value, a function runs. The problem is that when any of them are clicked, the function only runs for an extremely short amount of time.

My question is, how do I get the function to run indefinitely until the next else if is activated?

I'm guessing its such an easy bit of code but I cant quite figure it out.

Please see the if statement below:

    void controlEvent(ControlEvent theEvent) {

        if (theEvent.getController().getValue() == 0.0){

           drawPathToOutpatients();
        }

        else if (theEvent.getController().getValue() == 1.0){

          drawPathToRestaurant();
        }

        else if (theEvent.getController().getValue() == 2.0){

          drawPathToPharmacy();
        }

         else if (theEvent.getController().getValue() == 3.0){

          drawPathToWard1A();
        }
    }

Please see the function that is called below:

    void drawPathToOutpatients(){

      strokeWeight (3);
      dottedLine(720, 700, 720, 580);
      dottedLine(720, 580, 1080, 580);
      dottedLine(1080, 580, 1080, 670);
      dottedLine(1080, 670, 1160, 670);
      fill (0, 153, 102);
      text ("You Are Here", 690, 730);
      ellipse(720, 700, 20, 20);
      fill(0, 102, 153);
      ellipse(1160, 670, 20, 20);
      text("Outpatients", 1130, 720);
    }

Viewing all articles
Browse latest Browse all 2896

Trending Articles