How to Lock object created by indicator?

 

Suppose the indicator created a Label object on the chart by  ObjectCreate ,

Now the user draws a trendline for himself,

and He regrets it and clears his trendline with the  backspace  button.

The problem is that if He hits the  backspace  again, He can also delete the object created by the indicator, and this is not good.

What can we do to prevent the user from deleting objects created by the indicator with the backspace button?

I used  OBJPROP_SELECTED ,  OBJPROP_SELECTABLE ,  OBJPROP_HIDDEN  but it's not lock my object.

ObjectCreate(0,label, OBJ_LABEL, 0, 0, 0);
ObjectSet(label, OBJPROP_BACK, 1);
ObjectSetInteger(0,label,OBJPROP_SELECTED,false);
ObjectSetInteger(0,label,OBJPROP_SELECTABLE,false);
ObjectSetInteger(0,label,OBJPROP_HIDDEN,true);

 
Sinac: What can we do to prevent the user from deleting objects created by the indicator with the backspace button?

Nothing; he can always delete any object via Charts → Objects → Objects List (Control+B). Deal with it.

 
William Roeder:

Nothing; he can always delete any object via Charts → Objects → Objects List (Control+B). Deal with it.


What can we do to prevent the user from deleting objects created by the indicator with the backspace button?

Pay attention please: Backspace button
 
Sinac:

Suppose the indicator created a Label object on the chart by  ObjectCreate ,

Now the user draws a trendline for himself,

and He regrets it and clears his trendline with the  backspace  button.

The problem is that if He hits the  backspace  again, He can also delete the object created by the indicator, and this is not good.

What can we do to prevent the user from deleting objects created by the indicator with the backspace button?

I used  OBJPROP_SELECTED ,  OBJPROP_SELECTABLE ,  OBJPROP_HIDDEN  but it's not lock my object.

void OnChartEvent(const int id, const long& lparam, const double& dparam, const string& sparam)
  {
// 32=BackSpaceCode detail for https://www.w3.org/2002/09/tests/keys.html
   if(id==CHARTEVENT_KEYDOWN && lparam==32) ObjectDelete(label);
  }
 
Sinac:

What can we do to prevent the user from deleting objects created by the indicator with the backspace button?

Pay attention please: Backspace button
  1. I don't know why making it un-selectable doesn't fix it. But since you tried that, the answer is still “nothing.”
  2. What part of “Deal with it” was unclear? If it gets deleted, put it back. Done