How to send a chr(14) or backspace to a string

BlitzMax Forums/BlitzMax Beginners Area/How to send a chr(14) or backspace to a string

Takis76(Posted 2015) [#1]
Hello,

I use ifsogui and I would like to have a limit of input in textboxes.
I count the length of the characters and I subtract my number of characters minus the length of characters typed in the textbox.

Then the difference of my allowed characters minus the typed characters is 0 I would like to send the backspace key to avoid exceed the length of the string.

How is it possible to send or simulate the backspace key when I type something in a textbox.

The current code is so far like this:


The gadget creation code:

Global Description: ifsoGUI_TextBox
Level_Description_text = ifsoGUI_TextBox.Create(645, 663, 410, 23, "Level Description text", "Type the description of the selected level here...")
Level_Description_text.SetGadgetColor(255, 255, 255)
Level_Description_text.SetShowFocus(False)

GUI.AddGadget(Level_Description_text)


The gadget event code:

Local Description_of_level_char_length:Byte
If e.gadget.Name = "Level Description text" And e.id = ifsoGUI_EVENT_CHANGE Then
			
Description_of_level_char_length = 50 - Len(Level_Description_text.GetText())

'Try to do something like this and doesn't work
If Description_of_level_char_length <= 1 Then Level_Description_text.SetText(Level_Description_text.GetText() + Chr(14))



I try to send the chr(14) at the end of the string and it doesn't work.
Or when the user types something the backspace must be typed instead of more characters. Something like simulating the backspace.

Thank you :)


Brucey(Posted 2015) [#2]
Why not something like...
Local text:String = Level_Description_text.GetText()
If text.Length > 50 Then
    Level_Description_text.SetText(text[..50])
End If



Takis76(Posted 2015) [#3]
It worked. Thank you very much :)