Mouse Functions
The mouse functions allow EFS scripts to detect the bar index and Y-axis value of a mouse click on an Advanced chart. To enable the onLButtonDown or onLButtonDblClk mouse click functions add one of the following to an EFS formula. However, if both functions are used within the same EFS, beware that the onLButtonDown function will be called on the first click of the onLButtonDblClk event.
function onLButtonDown( barIndex, yValue) {
}
function onLButtonDblClk( barIndex, yValue) {
}
Example:
//Load the formula and try a left click and a left double click. function preMain() { setPriceStudy(true); setStudyTitle("Left Mouse Button Clicks"); setShowCursorLabel(false); } function main() {} function onLButtonDown(barIndex, yValue) { debugPrintln("LeftDown: " + barIndex + ", " + yValue); updateClickInfo(barIndex, yValue); } function onLButtonDblClk(barIndex, yValue) { debugPrintln("LeftDblClk: " + barIndex + ", " + yValue); updateDblClickInfo(barIndex, yValue); } function updateClickInfo(barIndex, yValue) { drawTextAbsolute( 5, 15, "Clicked bar " + barIndex + " at " + yValue.toFixed(2), Color.white, Color.navy, Text.RELATIVETOLEFT | Text.RELATIVETOBOTTOM | Text.BOLD, null, 14, "ClickInfo" ); } function updateDblClickInfo(barIndex, yValue) { drawTextAbsolute( 5, 35, "Double Clicked bar " + barIndex + " at " + yValue.toFixed(2), Color.white, Color.navy, Text.RELATIVETOLEFT | Text.RELATIVETOBOTTOM | Text.BOLD, null, 14, "DblClickInfo" ); }