imageButton

imageButton( )

Description

Draws a imageButton widjet

type of file       :   jpg, png
location of  file :   <Gallery -- Downloads> in your smart phone

Syntax
button(s1, s2, x, y, w, h, id) 

Parameters
  s1 : image before click to button
  s2 : image during  click to button
  x   : x-coordinate
  y   : y-coordinate

  w : width
  h : height

  id : id of button (range : 1 ~ 99)


Usages

imageButton("before.jpg", "after.jpg", 100, 200, 120, 80, 1)



Examples in arduino

#include "AppGosu.h"
AppGosu app;

int LED = 13;

void setup() {    
 
  pinMode(LED,OUTPUT);
  digitalWrite(LED, HIGH); // LED on

  app.start();
  app.setDelayCmd(20);  // max speed 20ms
  myStart();
}

void loop() {

 
} // end of loop

//---------------------------------------------------------
void serialEvent() {
      app.serialMessage();
      EventLoop();
}
void EventLoop() {
    if( app.btConnected()) {   // for auto starting
        myStart();
    }
  
    // user event code here
    app.textSize(30);
  
        if( app.eventImageButton(1)) {     // event handler of  imageButton
            app.background(0,0,0);
            app.text("--- imageButton ---", 20, 50);
            app.text("pressed  : " + (String)"1", 20, 50+100*6);
            digitalWrite(LED,HIGH); // LED on
        }
        if( app.eventImageButton(2)) {
            app.background(0,0,0);
            app.text("--- imageButton ---", 20, 50);
            app.text("pressed  : " + (String)"2", 320, 50+100*6);
            digitalWrite(LED, LOW); // LED off                
        }
  

}
//---------------------------------------------------------
void myStart(void) {
    // user starting code here
    app.clearAll();
    app.background(0,0,0);
    app.textSize(50);
    app.fill(255,255,255);
    app.text("--- imageButton ---", 20, 50);
  
    // imageButton
    app.imageButton("ledOn.png","ledOff.png", 90, 100*3, 150, 280, 1);
    app.imageButton("ledOff.png","ledOn.png", 290, 100*3, 150, 280, 2);

}






from AppGosu
-----------------------------------------







No comments: