Login Page - Create Account

Support Board


Date/Time: Sun, 05 May 2024 23:37:13 +0000



[Programming Help] - when sc.IsKeyPressed_Control true, not getting a sc.CharacterEventCode

View Count: 721

[2019-02-06 19:23:31]
User153286 - Posts: 44
I am trading via the DOM. I have created a keyboard short cut Cntrl-t which clears the recent bid/ask trades. The short-cut key works as required.

I have also created a study that attempts to capture the Cntrl-t. In the study I can the event from pressing the Cntrl key and I can get just the 't' key. I do not get the 't' when the Cntrl key is pressed. I can not identify that the user pressed both Cntrl and t.

the study does get an even in the KeyboardKeyEventCode windows virtual key code with a value of 17 which is the Cntrl key ( 0x11 ) itself

I would expect to see the Cntrl key and then the t (116 ascii) but this does not occur. If the Cntrl key is pressed, the keyboard key pressed is not seen by the study. (I tried other Cntrl combinations such as Cntrl-w).

I also tried this study in a simple chart getting , thinking this may be related to be in the DOM), but I got the same results


Interesting note. If I move the cursor onto my windows desktop and press the Cntrl Key, Sierra picks up the press of the Cntrl key. But if I press the keyboard key, such as 't' it does not pick it up. I would not think Sierra would pick up the Cntrl key if the dialog does not have focus. It seems Sierra picks the press of the Contrl key when the event occurs in any windows program on my system.

This issue was mentioned in post 68645 where your response indicated this was related to the OS. That does not make since I can get both the Cntrl key and the 't' key separately.

Also, the examples in the study cpp files never do both; they do either a control key or a simple key such as 't', but not the capture of a combination event such as cntrl-t


here is my simple example code that illustrates this issue






#include "sierrachart.h"
SCDLLName("Custom Study DLL")
/*==========================================================================*/

SCSFExport scsf_DepthOfMarketData(SCStudyInterfaceRef sc) //scsf_DOMAccess
{
  SCString Buffer;

  if (sc.SetDefaults)
  {

    sc.GraphName = "Keyboard Test ";
    sc.StudyDescription = "Keyboard test ";
    sc.GraphRegion = 0;
    sc.AutoLoop = 0;
    sc.ReceiveKeyboardKeyEvents = 1;
    sc.ReceiveCharacterEvents = 1;
    sc.UpdateAlways = 1;
    sc.SupportKeyboardModifierStates = 1;

    return;
  }


  if( sc.IsKeyPressed_Control )
  {
      Buffer.Format("control key pressed %i %i ",sc.CharacterEventCode);
    sc.AddMessageToLog(Buffer,0);


    if (sc.KeyboardKeyEventCode != 0)
    {
      Buffer.Format("Received keyboard key event. Windows virtual key code: %i, ", sc.KeyboardKeyEventCode);
      sc.AddMessageToLog(Buffer, 0);
    }

    if(sc.CharacterEventCode != 0)
    {
      Buffer.Format("Received character event. ASCII code: %i, ", sc.CharacterEventCode);
      sc.AddMessageToLog(Buffer, 0);
    }

  }

  if(sc.CharacterEventCode != 0)
  {
    Buffer.Format("JUST THE KEY Received character event. ASCII code: %i, ", sc.CharacterEventCode);
    sc.AddMessageToLog(Buffer, 0);
  }





} // end of study

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account