| Summary: | Font dialog doesn't return selected Font (when opened after MULTI Text) | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Lakshmi P Shanmugam <lshanmug> | ||||
| Component: | SWT | Assignee: | Scott Kovatch <skovatch> | ||||
| Status: | RESOLVED FIXED | QA Contact: | Silenio Quarti <Silenio_Quarti> | ||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | skovatch | ||||
| Version: | 3.6 | Flags: | lshanmug:
review+
|
||||
| Target Milestone: | 3.6.1 | ||||||
| Hardware: | PC | ||||||
| OS: | Mac OS X | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
This is only an issue when the multi-line Text has focus. If you move focus to the Button first and then set the font it will work. Created attachment 168780 [details]
Fix
Found it. Active NSTextViews normally respond to changes in the font panel. Any selected text is updated to the new font selection, but if the NSTextView is not set to use rich text nothing happens. I'm not entirely sure why, but the font in the font panel is then re-set to the current font of the NSTextView. This has the effect of vetoing the font selection. Fix is to tell the NSTextView used for Text to not listen to NSFontPanel changes.
One-liner; for 3.6.1. Lakshmi, please review. You can send it to Silenio if you're not comfortable reviewing. Hi Scott, I think the patch is good. Fixed > 20100630 in 3.6.1 and HEAD. |
The Font Dialog doesn't return the selected Font. public class FontDialogBug { public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new RowLayout()); final Text t = new Text(shell, SWT.MULTI|SWT.BORDER); t.setText("Hello"); Button button = new Button(shell, SWT.PUSH); button.setText("set font"); button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { FontDialog d = new FontDialog(shell); FontData data = d.open(); System.out.println(data); if (data != null) t.setFont(new Font(display, data)); } }); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } } Happens when we create the Text with SWT.MULTI style. Doesn't happen with SWT.SINGLE.