Community
Participate
Working Groups
Hi, I'm creating a compound custom widget in RWT just like SWT, a Composite with a control inside it. Like this: public class CustomText extends Composite { private Text text; public CustomText(Composite parent, int style) { super(parent, SWT.NONE); setLayout(new FillLayout()); text = new Text(this, style); this.setTabList(new Control[]{text }); } .... In SWT the TAB and SHIFT-TAB navigation in custom widgets is just like any other control, it gains the focus and puts it in the inner control in the example above it would be the Text control the one that gains it and puts the cursor on it. But in RWT this behavior is different when a compound custom widget gains the focus, the one that is receiving it, is the container and it doesn't pass the focus to the inner control. In the example above would be the CustomText control, so in order to the inner control (Text) gains the focus the TAB key should be typed twice. I realize of this behavior putting focus listeners in the container control. I cannot do a work around since the traverse(int traversal) has been removed from the RWT API.
Created attachment 175936 [details] Snippet to reproduce I can reproduce this bug with the attached snippet. There are no key or traverse listeners involved, so it's just a client issue. The fix should be to let the client Composite implementation not take the keyboard focus. On the other hand, this brings up the question if we could support custom Control#setFocus() implementations ...
Turns out that it works for Composite but not for subclasses of Composite. For Composites, a tabIndex of -1 is rendered. The problem is that Composite is hard-wired in ControlLCAUtil#takesFocus(). As a workaround, you can call the super constructor with the SWT.NO_FOCUS style flag like so: - super(parent, SWT.NONE); + super(parent, SWT.NO_FOCUS);
*** Bug 346471 has been marked as a duplicate of this bug. ***
(In reply to comment #3) > *** Bug 346471 has been marked as a duplicate of this bug. *** Andreas, does the workaround in comment #2 work for you? Using: Composite c1 = new FormToolkit(parent.getDisplay()).createComposite(parent, SWT.NO_FOCUS);
*** Bug 365442 has been marked as a duplicate of this bug. ***
The workaround in comment #2 does not always work. When using a ScrolledComposite, only certain styles are accepted, not including SWT.NO_FOCUS (see ScrolledComposite.checkStyle). When using eclipse forms, a LayoutComposite gets created but I have no influence on that. I experienced the issue with following widgets: - ScrolledComposite - Form - FormHeading - TitleRegion - LayoutComposite In my opinion, these components should automatically add the no_focus flag, or at least give the possibility to do so.
Created attachment 223359 [details] Patch proposal