fyne
fyne copied to clipboard
Chinese input method string truncated when typing into `widget.NewEntryWithData'
I have set FYNE_FONT
to support Chinese char print, but when I use Chinese input method to type something into the entry, the string gets truncated.
Code:
package main
import (
"fmt"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/data/binding"
"fyne.io/fyne/v2/dialog"
"fyne.io/fyne/v2/widget"
"io/ioutil"
"os"
"path/filepath"
"time"
)
func main() {
err := os.Setenv("FYNE_FONT", "C:\\Windows\\Fonts\\STSONG.TTF")
if err != nil {
return
}
a := app.New()
w := a.NewWindow("突击")
fileName := binding.NewString()
entry := widget.NewEntryWithData(fileName)
entry.OnSubmitted = func(fileName string) {
now := time.Now().Format("20060102")
//currentDir, err := os.Getwd()
//if err != nil {
// dialog.ShowConfirm("Oops!", fmt.Sprintf("Getwd: %v", err), nil, w)
// return
//}
full := filepath.Join(fmt.Sprintf("%s - %s", now, fileName))
// 检测当前是否存在同名目录或文件
if _, err := os.Stat(full); err == nil {
dialog.ShowConfirm("Oops!", fmt.Sprintf("File or directory %s exists", full), nil, w)
return
} else if !os.IsNotExist(err) {
dialog.ShowConfirm("Oops!", fmt.Sprintf("Stat %s: %v", full, err), nil, w)
return
}
err = os.MkdirAll(full, os.ModeDir)
if err != nil {
dialog.ShowConfirm("Oops!", fmt.Sprintf("Fail to create directory %s: %v", full, err), nil, w)
return
}
// Write to file
err := ioutil.WriteFile(filepath.Join(full, "README.md"), []byte(fmt.Sprintf("# %s\n", fileName)), os.ModeAppend)
if err != nil {
dialog.ShowConfirm("Oops!", fmt.Sprintf("Fail to WriteFile %s: %v", full, err), nil, w)
return
}
dialog.ShowInformation("OK", "OK", w)
}
w.Resize(fyne.NewSize(400, 500))
w.SetContent(container.NewVBox(
widget.NewLabel("Please input tuji directory name"),
entry,
))
w.ShowAndRun()
}
gets:


I also have this problem using Microsoft Pinyin input
If possible could you please help test feature/go-text
branch to see if this is a problem there as well?
We are working to replace the text shaping to vastly improve international support.
I also encountered this problem when using the MacOS version of Sogou Pinyin input
@zxdstyle Can you please help by testing the feature/go-text
branch mentioned above?
@zxdstyle Can you please help by testing the
feature/go-text
branch mentioned above?
Of course, but I didn't find the branch you mentioned
My apologise, the branch is on my fork, https://github.com/andydotxyz/fyne/commits/feature/go-text
After my test, the branch still has the same problem
replace fyne.io/fyne/v2 v2.1.3 => github.com/andydotxyz/fyne/v2 v2.0.3-0.20220123133908-c62fd89b6c1d
It looks to me like it changed slightly - with the branch it works the first time, but then as more characters are added it breaks. Is that accurate?
Indeed it is
I also encountered the problem of inputting Chinese fonts, the program crashed when inputting more characters, and the input method selection box did not follow in the input box
come here from #2660 ,yes same problem in NewMultiLineEntry