How to disable the backspace key event.

To add comments, please log in or register
ehongyao123
81
ehongyao123  

i have create some objects on chart. but if i press the backspace button on keyboard. these objects will be deleted on chart. 

how can i disable this event . thanks . 

ehongyao123
81
ehongyao123  
someone help me , thanks .
Hadil Mutaqin SE
2763
Hadil Mutaqin SE  
ehongyao123:

i have create some objects on chart. but if i press the backspace button on keyboard. these objects will be deleted on chart. 

how can i disable this event . thanks . 

Set selectable properties to false
Ex Ovo Omnia
3358
Ex Ovo Omnia  
Hadil Mutaqin SE:
Set selectable properties to false
Selectable or hidden have no effect on the backspace.
whroeder1
17944
whroeder1  
Ex Ovo Omnia: Selectable or hidden have no effect on the backspace.
Back space only deletes selected objects. Unselect them
honest_knave
Moderator
2302
honest_knave  
whroeder1:
Back space only deletes selected objects. Unselect them


OK, I'm guilty of resurrecting this thread (and then removing my post as I thought I shouldn't really be resurrecting old threads).

Unfortunately, backspace doesn't care if the object is selected or not. It will always delete the last object created.

As the thread is alive again (sorry!) I'll repost my solution:

The keystroke chartevent fires before the object gets deleted.

So the solution is to create a sacrificial object to be deleted.

This effectively inhibits backspace for the entire chart.

void OnChartEvent(const int id, const long& lparam, const double& dparam, const string& sparam)
  {
   if(id==CHARTEVENT_KEYDOWN && lparam==8) ObjectCreate(0,"Nothing",OBJ_LABEL,0,0,0);
  } 
Carl Schreiber
Moderator
7070
Carl Schreiber  
I have a keyboard that allows me to define macro scripts for every button and bind them to a defined program (e.g. ..\terminal). Maybe AutoHotkey provides this too? You have to try!
whroeder1
17944
whroeder1  
honest_knave: Unfortunately, backspace doesn't care if the object is selected or not. It will always delete the last object created.
Wrong, it only deletes select objects

honest_knave
Moderator
2302
honest_knave  
Carl Schreiber:
I have a keyboard that allows me to define macro scripts for every button and bind them to a defined program (e.g. ..\terminal). Maybe AutoHotkey provides this too? You have to try!


Unfortunately you cannot set backspace as a hotkey in the terminal to fire a script.

So the only solution (that I am aware of) is to have something running on the chart that can detect the backspace keystroke and create the sacrificial object before the delete gets actioned.

honest_knave
Moderator
2302
honest_knave  
whroeder1:
Wrong, it only deletes select objects


No,  I'm going with Ovo on this. It will delete objects that are not selected.

Drop this script onto a chart. Then make sure you click in the chart window to get the focus, and press backspace. Goodbye object!

void OnStart()
  {
   string name="my_object";
   ObjectCreate(0,name,OBJ_RECTANGLE_LABEL,0,0,0);
   ObjectSetInteger(0,name,OBJPROP_XDISTANCE,100);
   ObjectSetInteger(0,name,OBJPROP_YDISTANCE,100);
   ObjectSetInteger(0,name,OBJPROP_XSIZE,100);
   ObjectSetInteger(0,name,OBJPROP_YSIZE,100);
   ObjectSetInteger(0,name,OBJPROP_SELECTED,false);
   ObjectSetInteger(0,name,OBJPROP_SELECTABLE,false);
   ObjectSetInteger(0,name,OBJPROP_HIDDEN,true);
  }
honest_knave
Moderator
2302
honest_knave  

In addendum to my last, I can't recreate your animated gif.

This is what I believe you are doing:

  1. Create an object
  2. Select the object
  3. Create another object
  4. Press backspace

Your result: the first object (the selected one) is deleted

My result: the second object (the unselected one) is deleted.

Which build are you using?

12
To add comments, please log in or register