OBJ_BITMAP_LABEL -> Disable/Avoid automatic state change when clicked

 
I'm using OBJ_BITMAP_LABEL objects as buttons, but I want  some of them to react when clicked and some of them only when pressed.

Example:

I want a custom button (OBJ_BITMAP_LABEL) to behave as "MT4 One click trade", it is, when pressed, I want it to change state (to 1), to be shown as pressed, and when I release it, I want the state get back to 0. (Now, by default, it will change its state when released, not when pressed).

I want to manage every event, I would like to disable automatic state change when I release the button.

I guess it's not complicated, but I haven't found how to do it...
 

What's your problem actually ?

Please show your code if you need coding help.

 

Hi Alain,

My problem is I was trying to capture the "mouse pressed event", as long as I thought it would be much easier and it was me who doesn't find how to do it, but after searching for a while longer, I'm beginning to be afraid of this can't be done :(

Right now I was trying to find out how to do it according to this thread:

https://www.mql5.com/en/forum/157474

But I don't understand how they get to do it this way.

So, in short, my base-question is that, Is it possible to capture the "mouse pressed event" isolated?

In other words, Is it possible to emulate the One Click Trading buttons (they change their state as soon as you press them, no need to release them) using the API? Or is it just impossible?


PS: Still no existing code since I don't know how to code it :/

EDIT:

The only code I'm using, just for testing, though I can't detect the "pressed mouse", is this one:


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

   Print("lparam = "+lparam);
   Print("dparam = "+dparam);
   Print("sparam = "+sparam);

   if(id==CHARTEVENT_MOUSE_MOVE)
     {
      Print("CHARTEVENT = CHARTEVENT_MOUSE_MOVE");
     }

   if(id==CHARTEVENT_CUSTOM)
     {
      Print("CHARTEVENT = CHARTEVENT_CUSTOM");
     }

   if(id==CHARTEVENT_CLICK)
     {
      Print("CHARTEVENT = CLICK");
     }

   if(id==CHARTEVENT_OBJECT_CLICK)
     {
      Print("CHARTEVENT = OBJECT_CLICK");
     }
  }
Chart event when mouse button is pressed
Chart event when mouse button is pressed
  • 2015.11.11
  • www.mql5.com
Hi Gurus, Can I get a chart event, when I click on mouse button (BEFORE I release the button...
 

The solution is in the link your provided yourself. Seems to me very clear.

So, in short, my base-question is that, Is it possible to capture the "mouse pressed event" isolated?

Use the CHARTEVENT_MOUSE_MOVE event and check the sparam value. 

Mouse events (if property CHART_EVENT_MOUSE_MOVE=true is set for the chart)

CHARTEVENT_MOUSE_MOVE

the X coordinate

the Y coordinate

The string value of a bit mask describing the status of mouse buttons

We need the bit 1 to be set.

Of course you need to check that the mouse is on your object.

 

Ok, I'm sure I'll be able to get it studing a bit more these functions, so just knowing you don't tell me it's impossible are great news :) THANKS.

Second question,  for when I get it, is: Can I disable the automatic OBJ_BITMAP_LABEL state change when mouse is released over it? I can't be sure until I test it, but I presume it's going to conflict with my event handling (I'm thinking when I want to set the state to 0 because I release the mouse, MT4 is going to set it back to 1 because that is the default behaviour on these objects). I know I can achieve it enabling the selection of the object; I want to know whether I can do it without enabling it.

In short: Can I ask MT4 to please don't change the state of my OBJ_BITMAP_LABEL  objects even when selection on them is disable?

 
algarc:

Ok, I'm sure I'll be able to get it studing a bit more these functions, so just knowing you don't tell me it's impossible are great news :) THANKS.

Second question,  for when I get it, is: Can I disable the automatic OBJ_BITMAP_LABEL state change when mouse is released over it? I can't be sure until I test it, but I presume it's going to conflict with my event handling (I'm thinking when I want to set the state to 0 because I release the mouse, MT4 is going to set it back to 1 because that is the default behaviour on these objects). I know I can achieve it enabling the selection of the object; I want to know whether I can do it without enabling it.

In short: Can I ask MT4 to please don't change the state of my OBJ_BITMAP_LABEL  objects even when selection on them is disable?

Nothing is impossible ;-)
 

I deleted last question (/last comment) since I've realised it's already answered.

Thanks again Alain!!

PS: Well, I'm not sure... :S Is it possible to ask MT4 to not change the state of the object when clicked?
 
algarc Is it possible to ask MT4 to not change the state of the object when clicked?
When you get a click on the object, clear the setting.
          Indicators: 'Money Manager Graphic Tool' indicator by 'takycard' Forum - Page 5
 

I couldn't have expected a better proof of I can't disable that behaviour and that resetting the object is the best solution.

No doubts left.

Thanks whroeder1!

Reason: