David,
I had put together an example. Here it is:
I also attached the file
Regards,
I had put together an example. Here it is:
PHP Code:
var flg = Text.RELATIVETOLEFT|Text.RELATIVETOTOP| Text.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(){
drawTextPixel( xx, yy, nButtonTitle +" @URL=EFS:catchme", forcolor, backcolor, flg,"Comic Sans MS", 20, -5);
}
function catchme( nButtonPressed ){
if ( getButtonPressed( nButtonPressed ) == 1 ) {
debugPrintln("BUTTON_LEFT - Left Button Clicked");
xx = 480;
yy = 40;
nButtonTitle = "Click me with the right button!!";
backcolor = Color.red;
forcolor = Color.white;
}
if ( getButtonPressed( nButtonPressed ) == 2 ) {
debugPrintln("BUTTON_RIGHT - Right Button Clicked");
xx = 600;
yy = 100;
nButtonTitle = "Left Double-Click me!!";
backcolor = Color.white;
forcolor = Color.black;
}
if ( getButtonPressed( nButtonPressed ) == 3 ) {
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 ( getButtonPressed( nButtonPressed ) == 0 ) {
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);}
}
Regards,
Comment