Summary: | [WIN32] FocusIn listener on Text field does not select all text with selectAll call | ||
---|---|---|---|
Product: | [Eclipse Project] Platform | Reporter: | Lars Vogel <Lars.Vogel> |
Component: | SWT | Assignee: | Platform-SWT-Inbox <platform-swt-inbox> |
Status: | NEW --- | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | CC: | Lars.Vogel, niraj.modi |
Version: | 4.17 | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | Windows 10 | ||
See Also: | https://bugs.eclipse.org/bugs/show_bug.cgi?id=46059 | ||
Whiteboard: |
Description
Lars Vogel
2020-12-02 04:20:48 EST
(In reply to Lars Vogel from comment #0) > I would like a text widget that selects all of its text when it gains focus. > This doesn't appear to be currently supported by SWT. > // This does not work > text.addListener(SWT.FocusIn, event -> text.selectAll()); Hi Lars, Got the snippet working by wrapping 'selectAll()' into a display.asyncExec() as below: text.addListener(SWT.FocusIn, event -> display.asyncExec(() -> text.selectAll())); (In reply to Niraj Modi from comment #1) > (In reply to Lars Vogel from comment #0) > > I would like a text widget that selects all of its text when it gains focus. > > This doesn't appear to be currently supported by SWT. > > // This does not work > > text.addListener(SWT.FocusIn, event -> text.selectAll()); > > Hi Lars, > Got the snippet working by wrapping 'selectAll()' into a display.asyncExec() > as below: > text.addListener(SWT.FocusIn, event -> display.asyncExec(() -> > text.selectAll())); Sounds like my workaround from comment 0 (I have to wrap it into a display.asyncExec(() -> text.setSelection(0, text.getText().length()))) But IMHO this should not be necessary and we have a bug in SWT. WDYT? |