CHARTEVENT_KEYDOWN question

 

when you focus an OBJ_EDIT.

Please have a look on this code:


void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//---
        switch(id)
      {
         case CHARTEVENT_KEYDOWN:
         {
            do_something();
         }break;
     }       
}

Function do_something is not called, when the focus is on a OBJ_EDIT field and press a key.

When i click on the chart, then press a key again, the function is called.


Anyone has an idea how to catch keytrokes, when the focus is not in the chart ?

(.mql4)


Thank you

 
chinaski: Anyone has an idea how to catch keytrokes, when the focus is not in the chart ?

If the chart doesn't have focus, you shouldn't be trying to catch them. The terminal is processing them. Do you really want to override all keyboard short cuts of the terminal?

 
chinaski:
...

Anyone has an idea how to catch keytrokes, when the focus is not in the chart ?

(.mql4)


Thank you

You mean when the focus is on OBJ_EDIT, which is not exactly the same ?

What are you trying to achieve ?

 
whroeder1:

If the chart doesn't have focus, you shouldn't be trying to catch them. The terminal is processing them. Do you really want to override all keyboard short cuts of the terminal?

Why not ? If a gui element has the focus its not unusual to catch key strokes. I can ignore them end let them processed by another window.

 
whroeder1:

If the chart doesn't have focus, you shouldn't be trying to catch them. The terminal is processing them. Do you really want to override all keyboard short cuts of the terminal?

And why this means that i need to override all ? The chart is the parent window. As i can't directly handle events for each client in this parent,

it is suitable to provide events in OnChartEvent, in particular when this function provides several params to identify the element.

In OnChartEvent, i have the option to handle it or not. 

I really don't understand the design of this. For me, it is, in comparison to Win32  API in some, cases very strange which just forces you

to make time expensive workarounds (like focus or lbutton up event, which has to be catched by checking button pressed and mouse move).