none
error: Controls.TextTyped RRS feed

  • Question

  • I have continued to add examples for each MSB command. When I came across the Controls.TextTyped I keep getting an error. I can get TextInput to work fine.

    1) What am I doing wrong?

    2) Also, what is the difference between Controls.TextTyped vs GraphicsWindow.TextInput ?

    --------------

    txtBox = Controls.AddTextBox(125, 50)   ' name and create text box
    Controls.TextTyped = txtTyped               ' subroutine to handle textbox events

    Sub txtTyped ' msb requires one routine to handle all textboxes
      If (GraphicsWindow.LastText = txtBox) then ' action for text box
        GraphicsWindow.DrawText(150, 100, "Text boxed typed") 
      EndIf
    EndSub  


    Update: error caused by mismatch of "Control" and "GraphicsWindow" test.
    • Edited by jwzumwalt1 Thursday, September 7, 2017 9:51 AM
    Wednesday, September 6, 2017 12:50 PM

Answers

  • Controls.TextTyped is for text typed in a textbox control

    GraphicsWindow.TextInput is for keys entered on the GraphicsWindow, e.g. WASD for game control

    GraphicsWindow.LastText is last key on GW, not a textbox label as you used it - since nothing was entered on the GW it is emply hence possibly the crash (should be used with GraphicsWindow.TextInput event)

    Type inside or outside the TB to see the difference.

    txtBox = Controls.AddTextBox(125, 50)   ' name and create text box
    Controls.TextTyped = OnTextTyped               ' subroutine to handle textbox events
    GraphicsWindow.TextInput = OnTextInput
    
    Sub OnTextTyped ' msb requires one routine to handle all textboxes
      If (Controls.LastTypedTextBox = txtBox) then ' action for text box
        GraphicsWindow.DrawText(150, 100, "Text boxed typed "+Controls.GetTextBoxText(txtBox)) 
      EndIf
    EndSub  
    
    Sub OnTextInput
      GraphicsWindow.DrawText(150, 200, "Text typed "+GraphicsWindow.LastText) 
    EndSub

    • Proposed as answer by jricestkEditor Wednesday, September 6, 2017 6:00 PM
    • Marked as answer by jwzumwalt1 Thursday, September 7, 2017 9:47 AM
    Wednesday, September 6, 2017 5:35 PM
    Moderator

All replies

  • Controls.TextTyped is for text typed in a textbox control

    GraphicsWindow.TextInput is for keys entered on the GraphicsWindow, e.g. WASD for game control

    GraphicsWindow.LastText is last key on GW, not a textbox label as you used it - since nothing was entered on the GW it is emply hence possibly the crash (should be used with GraphicsWindow.TextInput event)

    Type inside or outside the TB to see the difference.

    txtBox = Controls.AddTextBox(125, 50)   ' name and create text box
    Controls.TextTyped = OnTextTyped               ' subroutine to handle textbox events
    GraphicsWindow.TextInput = OnTextInput
    
    Sub OnTextTyped ' msb requires one routine to handle all textboxes
      If (Controls.LastTypedTextBox = txtBox) then ' action for text box
        GraphicsWindow.DrawText(150, 100, "Text boxed typed "+Controls.GetTextBoxText(txtBox)) 
      EndIf
    EndSub  
    
    Sub OnTextInput
      GraphicsWindow.DrawText(150, 200, "Text typed "+GraphicsWindow.LastText) 
    EndSub

    • Proposed as answer by jricestkEditor Wednesday, September 6, 2017 6:00 PM
    • Marked as answer by jwzumwalt1 Thursday, September 7, 2017 9:47 AM
    Wednesday, September 6, 2017 5:35 PM
    Moderator
  • Thanks... I would have never figured that out from the documentation.

    Thanks to your example, I also see the reason my program failed
    was because I made a call using a "Controls" command, and tested
    using a "GraphicsWindow" command :(

    Thursday, September 7, 2017 9:49 AM