none
LDTextWindow.LastKey Doesn't seem to work RRS feed

  • Question

  • Here's a snippet:

    TextWindow.ReadKey()
    TextWindow.WriteLine(LDTextWindow.LastKey)

    If you run this you will see that if you hit a letter key it always shows "None". Shouldn't it actually show the key that was hit? It's interesting that they system does know that a key was entered, but LD command doesn't show it.


    JR


    • Edited by jricestkEditor Thursday, December 29, 2016 11:32 AM Update
    Thursday, December 29, 2016 11:29 AM
    Answerer

Answers

  • LDTextWindow.LastKey is only set when the event LDTextWindow.KeyDown event fires.  Perhaps this method should be somewhere else, but it is most usefull associated with TextWindow, since GraphicsWIndow has its own key events.

    It can be used in certain TW applications (and other special cases) where you want to detect key strokes that are not otherwise detectable.  For example a tab could move cursor to different locations within TW and read input data where TextWindow.Read wouldn't work, e.g. in a TW based game.


    • Marked as answer by jricestkEditor Thursday, December 29, 2016 12:46 PM
    Thursday, December 29, 2016 12:20 PM
    Moderator

All replies

  • LastKey is a low level event - not just in TextWindow.  Works whatever window has focus.

    Below is an example, but can be used in many other ways.

    This is not the issue you were describing about 2 versions 1 dayapart from November 2015?

    LDTextWindow.KeyDown = OnKeyDown
    TextWindow.ReadKey()
    
    Sub OnKeyDown
      TextWindow.WriteLine("Last Key = "+LDTextWindow.LastKey)
    EndSub

    Thursday, December 29, 2016 11:42 AM
    Moderator
  • LitDev,

    This is a separate issue from the .dll problem. I tried your code and it works fine. I guess I don't understand why my code doesn't work too. Shouldn't it show the last key that was entered? Why would I have to create an event subroutine to capture it?

    Thanks,


    JR

    Thursday, December 29, 2016 12:06 PM
    Answerer
  • LDTextWindow.LastKey is only set when the event LDTextWindow.KeyDown event fires.  Perhaps this method should be somewhere else, but it is most usefull associated with TextWindow, since GraphicsWIndow has its own key events.

    It can be used in certain TW applications (and other special cases) where you want to detect key strokes that are not otherwise detectable.  For example a tab could move cursor to different locations within TW and read input data where TextWindow.Read wouldn't work, e.g. in a TW based game.


    • Marked as answer by jricestkEditor Thursday, December 29, 2016 12:46 PM
    Thursday, December 29, 2016 12:20 PM
    Moderator