OnChartEvent

 

I have a situation where I want my code to do something when eg. a trendline is clicked.

I also want to be able to move the line without the code being executed.

My problem is that when I double click to select the line to move it, the first of the 2 clicks activates the  CHARTEVENT_OBJECT_CLICK and executes the code.

I can't make a condition that checks whether the object is selected, because the object is not selected until the 2nd click.

I can't think of a work around.

Any ideas?

Thanks 

 
I know that I can do it by pressing a key before and using CHARTEVENT_OBJECT_KEYDOWN to create a flag, but I was just wondering about a different way
 
GumRai:
I know that I can do it by pressing a key before and using CHARTEVENT_OBJECT_KEYDOWN to create a flag, but I was just wondering about a different way

Create an additional Button which when clicked performs the required action. 

 

A variant of sxTed's idea: create a small innocuous button that acts as a toggle. When clicked, the CHARTEVENT_OBJECT_CLICK code doesn't fire. Once you're done, toggle your small button back again. 

 

Or, turn on single-click object selection and make your other code work on a double-click (will need code to measure the time interval in order to establish whether it was as double-click).

 

 
sxTed:

Create an additional Button which when clicked performs the required action. 

 

honest_knave:

A variant of sxTed's idea: create a small innocuous button that acts as a toggle. When clicked, the CHARTEVENT_OBJECT_CLICK code doesn't fire. Once you're done, toggle your small button back again. 

Yes, I think that is the way to go.

Thanks 

Reason: