Object click priority always to rectangle label?

Back to topics list To post a new topic, please log in or register
avatar
736
honest_knave 2014.11.10 17:52
 

I have noticed that Rectangle Labels receive click priority over Labels, irrespective to the z-order assignment. Is this behavior deliberate?

This can be seen by creating a rectangle label with z-order 0, which partially overlaps a label with z-order 100.

When clicking on the "So" text not over the rectangle label:

 

When clicking on the "e Text" text over the rectangle label:

 

 So the higher z-order of the label is being ignored when it overlaps a rectangle label. 

#property strict
#property indicator_chart_window

int OnInit() {
   string name="Rectangle Label";
   ObjectCreate(0,name,OBJ_RECTANGLE_LABEL,0,0,0);
   ObjectSetInteger(0, name, OBJPROP_BGCOLOR,  clrWhite);
   ObjectSetInteger(0, name, OBJPROP_XDISTANCE,100);
   ObjectSetInteger(0, name, OBJPROP_YDISTANCE,100);
   ObjectSetInteger(0, name, OBJPROP_XSIZE,    50);
   ObjectSetInteger(0, name, OBJPROP_YSIZE,    50);
   ObjectSetInteger(0, name, OBJPROP_ZORDER,   0);   
   
   name="Label";
   ObjectCreate(0,name,OBJ_LABEL,0,0,0);
   ObjectSetInteger(0, name, OBJPROP_COLOR,    clrMagenta);
   ObjectSetInteger(0, name, OBJPROP_XDISTANCE,80);
   ObjectSetInteger(0, name, OBJPROP_YDISTANCE,110);
   ObjectSetString (0, name, OBJPROP_TEXT,     "Some Text");
   ObjectSetInteger(0, name, OBJPROP_ZORDER,   100);
   return(INIT_SUCCEEDED);}

void OnDeinit(const int reason) {
   ObjectDelete(0,"Rectangle Label");
   ObjectDelete(0,"Label");}

int OnCalculate(const int rates_total,    const int prev_calculated,    const datetime &time[],
                const double &open[],     const double &high[],         const double &low[],
                const double &close[],    const long &tick_volume[],    const long &volume[],
                const int &spread[]) {
   return(rates_total);}

void OnChartEvent(const int id, const long& lparam, const double& dparam, const string& sparam) {
   if(id==CHARTEVENT_OBJECT_CLICK) {
      long z=ObjectGetInteger(0,sparam,OBJPROP_ZORDER);
      printf("I am %s, my z-order is %i",sparam,z);}}


avatar
2017
gooly 2014.11.10 22:32 #
 

Have you considered ObjectSetInteger() and the option OBJPROP_BACK (bool) = Object in the background?


avatar
736
honest_knave 2014.11.11 00:16 #
 

Thanks for the reply gooly. Unfortunately, it gives exactly the same result:

 

#property strict
#property indicator_chart_window

int OnInit() {
   string name="Rectangle Label";
   ObjectCreate(0,name,OBJ_RECTANGLE_LABEL,0,0,0);
   ObjectSetInteger(0, name, OBJPROP_BGCOLOR,  clrWhite);
   ObjectSetInteger(0, name, OBJPROP_XDISTANCE,100);
   ObjectSetInteger(0, name, OBJPROP_YDISTANCE,100);
   ObjectSetInteger(0, name, OBJPROP_XSIZE,    50);
   ObjectSetInteger(0, name, OBJPROP_YSIZE,    50);
   ObjectSetInteger(0, name, OBJPROP_ZORDER,   0);
   ObjectSetInteger(0, name, OBJPROP_BACK,     true);   
   name="Label";
   ObjectCreate(0,name,OBJ_LABEL,0,0,0);
   ObjectSetInteger(0, name, OBJPROP_COLOR,    clrMagenta);
   ObjectSetInteger(0, name, OBJPROP_XDISTANCE,80);
   ObjectSetInteger(0, name, OBJPROP_YDISTANCE,110);
   ObjectSetString (0, name, OBJPROP_TEXT,     "Some Text");
   ObjectSetInteger(0, name, OBJPROP_ZORDER,   100);
   ObjectSetInteger(0, name, OBJPROP_BACK,     false);
   return(INIT_SUCCEEDED);}

void OnDeinit(const int reason) {
   ObjectDelete(0,"Rectangle Label");
   ObjectDelete(0,"Label");}

int OnCalculate(const int rates_total,    const int prev_calculated,    const datetime &time[],
                const double &open[],     const double &high[],         const double &low[],
                const double &close[],    const long &tick_volume[],    const long &volume[],
                const int &spread[]) {
   return(rates_total);}

void OnChartEvent(const int id, const long& lparam, const double& dparam, const string& sparam) {
   if(id==CHARTEVENT_OBJECT_CLICK) {
      long z=ObjectGetInteger(0,sparam,OBJPROP_ZORDER);
      printf("I am %s, my z-order is %i",sparam,z);}}

 

avatar
1211
deysmacro 2014.11.11 01:59 #
 
If I not mistaken, z-order would work like it should if it is of the same type of object. Different object would have different z-order priority. In this case, that is most probably.
avatar
736
honest_knave 2014.11.11 10:17 #
 

Thanks for the reply. That may be the case, but sadly I have not found anywhere in the documentation what the hierarchy of objects is.

Also, the zorder seems to be working between certain object types. 

For example, Labels over Rectangle Labels, the rectangle label always wins.

Buttons over Rectangle Labels, the zorder system works correctly (even though they are different object types).

OBJPROP_ZORDER

Priority of a graphical object for receiving events of clicking on a chart (CHARTEVENT_CLICK). The default zero value is set when creating an object; the priority can be increased if necessary. When applying objects one over another, only one of them with the highest priority will receive the CHARTEVENT_CLICK event.

long

 

avatar
315
sunshineh 2014.12.22 09:12 #
 

Hi,

very interesting  thread! Has anybody a solution for that Problem?

avatar
Moderator
3206
angevoyageur 2014.12.22 20:15 #
 
sunshineh:

Hi,

very interesting  thread! Has anybody a solution for that Problem?

It's a mql4 bug (tested with  build 765). The same code works well with mql5.

Bugs have to be reported to ServiceDesk.

avatar
315
sunshineh 2014.12.23 08:23 #
 
Thanks a lot for that info! I hope the bug will be corrected soon because this would be a very useful functionality! 
avatar
2
killnight 2015.10.14 06:55 #
 

Still not solve this bug?

I am troubled by the same bug while I creating my Virtul Trade System.

It cost me 1 hour to try to find out WHY , untile I find this article.

I give up WHY and try to find HOW.Wana make a label with background? Just use two label with different ZOder,and a character string like this "█". Do not forget to set font to NULL.

Now I got every Order Label  with background.


post


Back to topics list  

To add comments, please log in or register