Merge pull request #278 from MurilloBrand/master

Fixing TextBox issue and adding Trim to other inputs
This commit is contained in:
Milan Nikolic 2023-08-26 18:00:40 +02:00 committed by GitHub
commit f770ca0981
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -751,12 +751,12 @@ func TextBox(bounds rl.Rectangle, text *string, textSize int, editMode bool) boo
if len(bs) == 0 {
bs = []byte{byte(0)}
}
//if 0 < len(bs) && bs[len(bs)-1] != byte(0) { // minimalize allocation
if 0 < len(bs) && bs[len(bs)-1] != byte(0) { // minimalize allocation
bs = append(bs, byte(0)) // for next input symbols
//}
}
ctext := (*C.char)(unsafe.Pointer(&bs[0]))
defer func() {
*text = strings.TrimSpace(string(bs))
*text = strings.TrimSpace(strings.Trim(string(bs), "\x00"))
// no need : C.free(unsafe.Pointer(ctext))
}()
@ -1072,7 +1072,7 @@ func TextInputBox(bounds rl.Rectangle, title, message, buttons string, text *str
}
ctext := (*C.char)(unsafe.Pointer(&bs[0]))
defer func() {
*text = string(bs)
*text = strings.TrimSpace(strings.Trim(string(bs), "\x00"))
// no need : C.free(unsafe.Pointer(ctext))
}()
@ -1106,7 +1106,7 @@ func TextBoxMulti(bounds rl.Rectangle, text *string, textSize int32, editMode bo
}
ctext := (*C.char)(unsafe.Pointer(&bs[0]))
defer func() {
*text = string(bs)
*text = strings.TrimSpace(strings.Trim(string(bs), "\x00"))
// no need : C.free(unsafe.Pointer(ctext))
}()