Download MetaTrader 5

OnChartEvent

To add comments, please log in or register
Publish your article and thousands of people all over the world will read it!
Keith Watford
Moderator
9624
Keith Watford 2015.04.01 02:08 

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 

Keith Watford
Moderator
9624
Keith Watford 2015.04.01 02:11  
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
Edward Hirsch
714
Edward Hirsch 2015.04.01 06:39  
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. 

honest_knave
Moderator
2209
honest_knave 2015.04.01 07:54  

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. 

honest_knave
Moderator
2209
honest_knave 2015.04.01 08:01  

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).

 

Keith Watford
Moderator
9624
Keith Watford 2015.04.01 09:15  
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 

To add comments, please log in or register