Problem with CHARTEVENT_OBJECT_CLICK, any ideas how to fix it?

 

If you have a selected horizontal line underneath a button and you click on the button while your mouse is over the horizontal line that's hidden by the button, even if the button has a higher OBJPROP_ZORDER value, the click's priority will be given to the horizontal line if you accidentally move your mouse by 1 pixel between the down click and the up click as MT5 will assume that you want to move/drag the horizontal line instead of clicking on the button.

This creates two problems:

1. You end up accidentally moving the horizontal line when you just want to click on the button

2. The click doesn't generate a CHARTEVENT_OBJECT_CLICK event on the button when this happens

My buttons are all on a rectangle label that hides the horizontal lines so what I can do to solve these problems is track the mouse movements with CHART_EVENT_MOUSE_MOVE and change the horizontal line's OBJPROP_SELECTED property to false while my mouse is over that rectangle label. It'll work, but do you think there might be a simpler and more efficient solution?

P.S. for this example, I need the horizontal lines to be selected, so simply leaving them unselected is not an option.

Thanks in advance!

Documentation on MQL5: Constants, Enumerations and Structures / Chart Constants / Types of Chart Events
Documentation on MQL5: Constants, Enumerations and Structures / Chart Constants / Types of Chart Events
  • www.mql5.com
Types of Chart Events - Chart Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
just an idea:
- you could "change the look (width, style, color, etc.)" of the selected line to indicate that it is currently selected (active), but set the line property to be not selectable using "OBJPROP_SELECTABLE" and if needed, rearrange its Z-order.
- later you might need a way to "deselect" that line again.

good luck.

 
Soewono Effendi #:
just an idea:
- you could "change the look (width, style, color, etc.)" of the selected line to indicate that it is currently selected (active), but set the line property to be not selectable using "OBJPROP_SELECTABLE" and if needed, rearrange its Z-order.
- later you might need a way to "deselect" that line again.

good luck.

thanks for the tip

so I just coded it and it wasn't that bad, maybe there is a way to fix this with an easier trick but if not, the code I wrote was simpler than I originally thought and only took a few extra lines of code so I'm not going to worry about it causing efficiency issues