How do I get a button defined in an *.efsLib library file to execute a function.
I can call the function directly so as far as I know it is defined but when called by:
"drawTextAbsolute(0, 11, " Toggle Band @URL=EFS:changeColor", Color.white, null, xFlags , "Courier New", 11, -55); "
and the button on the chart is clicked it returns:
"...line 0: Failed to call 'changeColor': function is not defined."
Here is a sample efs file: del b.efs
And the corresponding *.efsLib file: del_ButtonTest.efsLib
I would really appreciate some help.
Wayne
I can call the function directly so as far as I know it is defined but when called by:
"drawTextAbsolute(0, 11, " Toggle Band @URL=EFS:changeColor", Color.white, null, xFlags , "Courier New", 11, -55); "
and the button on the chart is clicked it returns:
"...line 0: Failed to call 'changeColor': function is not defined."
Here is a sample efs file: del b.efs
PHP Code:
debugClear();
var myLibrary = addLibrary ("del_ButtonTest.efsLib");
function main(){
myLibrary.callDraw();
}
PHP Code:
var bButtonPressed = false;
var bDrawBand = false;
function callDraw(){
var xFlags = Text.ONTOP | Text.BUTTON | Text.RELATIVETOLEFT | Text.RELATIVETOBOTTOM;
if ( isLastBarOnChart() && bDrawBand == true ) {
addBand( 0, PS_SOLID, 5, Color.black, -66 );
}
drawTextAbsolute(0, 11, " Toggle Band @URL=EFS:changeColor", Color.white, null, xFlags , "Courier New", 11, -55);
}
//== function determines if a button was pressed
function getButtonPressed(nButtonPressed) {
if(nButtonPressed == BUTTON_LEFT) {
return(1);
}
else {
return(0);
}
}
//== performs a specific task if our button was pressed
function changeColor( nButtonPressed ) {//code inside here executed immediately while in main it waits for a new tick
if ( getButtonPressed( nButtonPressed ) == 1 ) {
bButtonPressed = true;
bDrawBand = !bDrawBand;
clearBands();
main();
}
return;
}
Wayne
Comment