How to detect key_stroke in OBJ_EDIT?

 
 ObjectCreate(NULL,"calc_winOutput",OBJ_EDIT,0,NULL,NULL);

 ObjectSetString(NULL,"calc_winOutput",OBJPROP_TEXT,"0.000");

 ObjectSetInteger(NULL,"calc_winOutput",OBJPROP_BGCOLOR,clrLawnGreen);

 ObjectSetInteger(NULL,"calc_winOutput",OBJPROP_FONTSIZE,12);

 ObjectSetInteger(NULL,"calc_winOutput",OBJPROP_XSIZE,75);

 ObjectSetInteger(NULL,"calc_winOutput",OBJPROP_XDISTANCE,120);

 ObjectSetInteger(NULL,"calc_winOutput",OBJPROP_YSIZE,25);

 ObjectSetInteger(NULL,"calc_winOutput",OBJPROP_YDISTANCE,135);



////this isn't triggering any KEYDOWN events, when i type inside the OBJ_EDIT

void OnChartEvent()

{  
   if( id==CHARTEVENT_KEYDOWN && sparam=="calc_winOutput"  )Alert("pressed keycode: ",lparam);

}
 
anyone?????
 
Tusher Ahmed:
anyone?????

It's not clear to me exactly what you are asking.

Maybe you might want to use 

Perhaps you could describe precisely what you are expecting.

 
Keith Watford:

It's not clear to me exactly what you are asking.

Maybe you might want to use 

Perhaps you could describe precisely what you are expecting.

hi admin,

Here's the deal :

We can get key-codes at key-down event, right?

But how can we get key-codes when we are write/type inside  an  OBJ_EDIT (editable object)?

It seems like , when you type inside an OBJ_EDIT, you don't get any events triggered related to KEYDOWN.

 

Why i'm trying to detect keycodes?

Suppose i want users only to type numbers only, inside the entrybox/OBJ_EDIT.

So i don't want them to write anything other than numbers. When they press another "non-number keys", it must not type inside the entrybox!

 

I have never needed anything like that. Unless somebody comes up with an answer, you will need to experiment.

You should be able to detect when the edit object is clicked, and ENDEDIT when another part of the chart is clicked or the enter key pressed. So you may be able to check what has been entered and delete it if it is not a number.

 
Keith Watford:

I have never needed anything like that. Unless somebody comes up with an answer, you will need to experiment.

You should be able to detect when the edit object is clicked, and ENDEDIT when another part of the chart is clicked or the enter key pressed. So you may be able to check what has been entered and delete it if it is not a number.

so, there's no way to stop people typing  unwanted characters in the entryBox. All we can do is remove the unwanted chars after EndEdit.

Correct me if i'm wrong.

The tradepanel can be a great example where you would want to restrict people from typing anything other than numbers. 

If you type a "comma", it wont work here. Only thing works is : numbers & decimal point (dot)

no "commas" allowed

 
Tusher Ahmed:

so, there's no way to stop people typing  unwanted characters in the entryBox. All we can do is remove the unwanted chars after EndEdit.

Correct me if i'm wrong.

The tradepanel can be a great example where you would want to restrict people from typing anything other than numbers. 

If you type a "comma", it wont work here. Only thing works is : numbers & decimal point (dot)


That is not what I am saying. As I posted, I have never needed anything like that so I have never had to investigate it.

I have had times when I have needed to interpret an entered comma as a decimal point, but that is not the same as your requirement.

I can only guess that for what you want, you could use a rectangle label with a label placed on top. Then you could set the text according to whatever keys are pressed, ignoring key presses that don't apply.

Reason: