Note: This problem occurs only on Mac, on Windows works fine.
I have a SWT Text widget that I want quite large text inserted into.
//simplified large string from StringBuilder
String something="";
for(int i=0;i<10;i++){
something += smp1+"\t"+smp2+"\t"+smp3+"\n";
}
final Text text = new Text(shell, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL );
text.setBounds(10, 50, 880, 280);
text.setText(something);
The issue is that although there is way too much space (880px), the text breaks somewhere on 400px if there are more than two “\t” (tab) characters in the line. When writing in the textbox with ” ” (space), the line continues as it should, and doesn’t wrap.
Outputing the string to console shows it fine, so I don’t think that the issue is in the string, but rather in the Text control.
I tried everything I could think of, and no luck in solving it.
Any help is appreciated.
Widgets in SWT are drawn natively by the OS – that is sort of the point of this library.
That’s why OS-specific quirks are “preserved”.
But while
Textis drawn natively,StyledTextis not, it’s drawn “by hand” by SWT in order to provide advanced features for all supported platforms.So you might want to try
StyledTextinstead – yes, that’s only a workaround, and has the theoretical drawbacks of a non-native widget, like poorer performance, different behaviour, and so on, but most probably you won’t notice any difference. But if you’re lucky, it fixes your issue.