Detecting right mouse button click in MQL5

 

Please, what is the correct way to detect a right mouse button click in MQL5?

I am aware that, at the Windows level, the right mouse button is commonly represented by 0x02 . However, I am not sure whether relying on this value (for example by comparing lparam during CHARTEVENT_MOUSE_MOVE ) is reliable, which seems not to work.

I would appreciate experienced opinions on the best practice for handling right-click detection in MQL5. Any clarification or example would be of great use.

Thank you
 

CHARTEVENT_MOUSE_MOVE is the way to go.

 
Alain Verleyen #:

CHARTEVENT_MOUSE_MOVE is the way to go.

Thank you for your response.

indeed, CHARTEVENT_MOUSE_MOVE is the way as you said, but am finding it difficult to detect mouse-right click, while mouse is in motion / move.
 
Chukwubuikem Okeke #:
Thank you for your response.

indeed, CHARTEVENT_MOUSE_MOVE is the way as you said, but am finding it difficult to detect mouse-right click, while mouse is in motion / move.
You need to post your code if you want coding help.
 
Alain Verleyen #:
You need to post your code if you want coding help.

Someone is stuck here 

void OnChartEvent(const int32_t id, const long& lparam, const double& dparam, const string& sparam) {
//---

   switch(id) {

   case CHARTEVENT_OBJECT_CLICK:
      if(sparam == TOGGLE_BUTTON) {
         toggleButtonState(TOGGLE_BUTTON, isMenuON);
      }
      break;
   case CHARTEVENT_MOUSE_MOVE:
      if(lparam == 0X02) {
         Print("Right-click held also!");
      }
      break;
   }

}
 
Chukwubuikem Okeke #:

Someone is stuck here 

Why are you using lparam ? What the documentation said ?
 
Alain Verleyen #:
Why are you using lparam ? What the documentation said ?
Maybe i couldn't find anything in the documentation, thats why am here 


And it happened that you replied, which i do appreciate.

So do help out with the best logic or something
 
Chukwubuikem Okeke #:
Maybe i couldn't find anything in the documentation, thats why am here 


And it happened that you replied, which i do appreciate.

So do help out with the best logic or something
MQL5 Book: Mouse and keyboard control / Creating application programs
MQL5 Book: Mouse and keyboard control / Creating application programs
  • www.mql5.com
In this section, we will get acquainted with a group of properties that affect how the chart will capture certain mouse and keyboard manipulations...
 
MQL5 Book: Mouse events / Creating application programs
MQL5 Book: Mouse events / Creating application programs
  • www.mql5.com
We already had the opportunity to make sure that we receive mouse events using the indicator EventAll.mq5 from the section Event-related chart...
 

a working example. 

good luck.

Files:
mouse.mq5  3 kb
 
Thank you all for your replies .

Am so grateful. It's more than helpful 😊