Open tmssngr opened 6 months ago
Even worse: at the time when the first edit related event SWT.Verify
occurs, the selected character already has been magically replaced (st.getText()
does not contain it any more). This looks like a serious bug of the StyledText
control with Chinese (Pinyin) keyboard layout.
Workaround: use StyledTextContent
's TextChangeListener
instead of SWT.Verify
, SWT.Modify
or SWT.ExtendedModify
if you want to get access to the replaced text, e.g. for implementing an undo-feature.
Describe the bug If a selection in the StyledText is replaced with a Chinese letter entered using Chinese (Pinyin), no (replaced) text is reported by the
SWT.ExtendedModify
event.To Reproduce
sudo apt install ibus-pinyin
, Manjaro:sudo pacman -S ibus-pinyin
public class PinyinTest { public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new FillLayout()); final StyledText st = new StyledText(shell, SWT.BORDER); st.addListener(ST.ExtendedModify, event -> { System.out.printf("%d %d, '%s'(%d)\n", event.start, event.end - event.start, event.text, event.text.length()); });
}
d
d1
(replacingd
)-> although
d
has been replaced, it was not reported inevent.text
this timeExpected behavior Replacing with a Chinese character also should report the replaced character(s).
Environment:
Select the platform(s) on which the behavior is seen:
Additional OS info (e.g. OS version, Linux Desktop, etc) Tried with Ubuntu 22.04 and Manjaro/Gnome (latest)