Fix BackSpace in TextBox

This commit is contained in:
Milan Nikolic 2018-05-07 18:49:04 +02:00
parent 17a6f5c646
commit 07185b35c1

View file

@ -979,8 +979,6 @@ func TextBox(bounds raylib.Rectangle, text string) string {
b := bounds.ToInt32() b := bounds.ToInt32()
state := Normal state := Normal
keyBackspaceText := int32(259) // GLFW BACKSPACE: 3 + 256
mousePoint := raylib.GetMousePosition() mousePoint := raylib.GetMousePosition()
letter := int32(-1) letter := int32(-1)
@ -991,17 +989,16 @@ func TextBox(bounds raylib.Rectangle, text string) string {
framesCounter2++ framesCounter2++
letter = raylib.GetKeyPressed() letter = raylib.GetKeyPressed()
if letter != -1 { if letter != -1 {
if letter == keyBackspaceText {
if len(text) > 0 {
text = text[:len(text)-1]
}
} else {
if letter >= 32 && letter < 127 { if letter >= 32 && letter < 127 {
text = fmt.Sprintf("%s%c", text, letter) text = fmt.Sprintf("%s%c", text, letter)
} }
} }
if raylib.IsKeyPressed(raylib.KeyBackspace) {
if len(text) > 0 {
text = text[:len(text)-1]
}
} }
} }