Trapping mouse select-drag-drop events

 

My indicator tracks a date set by a vertical line every second (set by timer).  A long calculation is called if the vertical line is changed.  But when I click on the vertical line, while dragging to another price-bar and before releasing the click, the long calculation is called with whenever date the line was resting on during the dragging and called again after I release the click.

How do I detect the select-drag-drop events?  I want to only enable calculation after drop event (not while dragging).


void OnTick()
  {
    if (vertical_line_changed) call_long_calculation();
  }

void OnTimer()
  {
   OnTick();
  }
 
williamwong:

My indicator tracks a date set by a vertical line every second (set by timer).  A long calculation is called if the vertical line is changed.  But when I click on the vertical line, while dragging to another price-bar and before releasing the click, the long calculation is called with whenever date the line was resting on during the dragging and called again after I release the click.

How do I detect the select-drag-drop events?  I want to only enable calculation after drop event (not while dragging).


Use OnChartEvent() and CHARTEVENT_OBJECT_DRAG
 
Alain Verleyen:
Use OnChartEvent() and CHARTEVENT_OBJECT_DRAG

I understand CHARTEVENT_OBJECT_DRAG is sent while it is being dragged? or after dragged?  I think 2 events are needed to indicate the start of dragging and end of dragging.  What are these 2 events?

void OnTick()
  {
    if (start_check && vertical_line_changed) call_long_calculation();
  }

void OnTimer()
  {
   OnTick();
  }
void OnChartEvent(const int id,         // Event identifier   
                  const long& lparam,   // Event parameter of long type 
                  const double& dparam, // Event parameter of double type 
                  const string& sparam) // Event parameter of string type 
{
if(id==CHARTEVENT_OBJECT_DRAG_START) start_check=false;
else if(id==CHARTEVENT_OBJECT_DRAG_END) start_check=true;
}
Reason: