Announcement

Collapse
No announcement yet.

help on how to use the text button

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    David,

    I had put together an example. Here it is:
    PHP Code:
    var flg Text.RELATIVETOLEFT|Text.RELATIVETOTOPText.FRAME Text.ONTOP;
    var 
    xx 480;
    var 
    yy 0;
    var 
    nButtonTitle "Click me!!";
    var 
    backcolor Color.red;
    var 
    forcolor Color.white

    function preMain(){
        
    setPriceStudy(true); 
      
    setStudyTitle("Button Test"); 
    }
    // end preMain
    function main() {
      var 
    BarState getBarState();
      var 
    nIndex getCurrentBarIndex();     

        
    //----------------------------------------------------------------------------------------     
        
    if (nIndex < -60){return;} // minimizes load time
        
    if (BarState == BARSTATE_NEWBAR) {     
            
    barcount +=1;//debugPrintln("barcount = " +barcount);
            
    getButtons(); 
        }
        return;
    }

    function 
    getButtons(){
        
    drawTextPixelxxyynButtonTitle +" @URL=EFS:catchme"forcolorbackcolorflg,"Comic Sans MS"20, -5);
    }

    function 
    catchmenButtonPressed ){
        if ( 
    getButtonPressednButtonPressed ) == ) {
            
    debugPrintln("BUTTON_LEFT            - Left Button Clicked");
            
    xx 480;
            
    yy 40;
            
    nButtonTitle "Click me with the right button!!";
            
    backcolor Color.red;
            
    forcolor Color.white;
        }
        if ( 
    getButtonPressednButtonPressed ) == ) {
            
    debugPrintln("BUTTON_RIGHT        - Right Button Clicked");
            
    xx 600;
            
    yy 100;
            
    nButtonTitle "Left Double-Click me!!";
            
    backcolor Color.white;
            
    forcolor Color.black;
        }
        if ( 
    getButtonPressednButtonPressed ) == ) {
            
    debugPrintln("BUTTON_LEFTDBLCLK        - Left Button Double-Clicked");
            
    xx 170;
            
    yy 50;
            
    nButtonTitle "Click me with the left button!!";
            
    backcolor Color.yellow;
            
    forcolor Color.blue;
        }
        if ( 
    getButtonPressednButtonPressed ) == ) {
            
    debugPrintln("BUTTON_UNKNOWN            - Some Other Button Click");
            
    xx 200;
            
    yy 50;
            
    nButtonTitle "Click me with the right button!!";
            
    backcolor Color.yellow;
            
    forcolor Color.blue;
        }
        
    getButtons(); 
        return;
    }

    //BUTTON_RIGHT        - Right Button Clicked
    //BUTTON_LEFT            - Left Button Clicked
    //BUTTON_LEFTDBLCLK        - Left Button Double-Clicked
    //== function determines if a button was pressed and which on was pressed

    function getButtonPressed(nButtonPressed) {
      if(
    nButtonPressed == BUTTON_LEFT) {return(1);}
      if(
    nButtonPressed == BUTTON_RIGHT) {return(2);}
      if(
    nButtonPressed == BUTTON_LEFTDBLCLK) {return(3);}
        else {return(
    0);}

    I also attached the file


    Regards,
    Attached Files

    Comment


    • #17
      David,

      Did this help?


      Regards,

      Comment


      • #18
        yes it did steve, thx

        Comment

        Working...
        X