Home » Eclipse Projects » Remote Application Platform (RAP) » Tab sequence does not work properly for custom composite widgets extending Composite
Tab sequence does not work properly for custom composite widgets extending Composite [message #1802492] |
Mon, 11 February 2019 02:48 ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Clemens Gantert![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=cgan%40gmx.de) Messages: 6 Registered: August 2012 Location: CA, USA |
Junior Member |
|
|
Hi
I am using a custom composite widget that extends Composite to wrap a Text control. I am using this approach to have one control that depending on context renders to an input field, combo box, a check box, etc. The problem is that for my custom control I have to press the tab button twice instead of once to move the cursor from one to the next. I followed the composite widget example from https://www.eclipse.org/articles/Article-Writing%20Your%20Own%20Widget/Writing%20Your%20Own%20Widget.htm.
I also took a look at getTabList()/setTabList() but there seems no difference between a Composite that that a Text control as child and my custom composite.
I also looked into the TraverseEvent, but my handler seems to only be called the second time I press the tab button. I debugged the client a little bit and it appears that the first tab press is completely ignored in the client and there is no network traffic from the client to the backend either.
Here, is the code for which I can reproduce the problem in my setup (RAP 3.7, view in a workbench, theming ):
public class TabSequenceTest extends BasePage {
private Group currentGroup;
public TabSequenceTest(Composite parent,
final TransitionHandlerFactory transHandlerFactory,
final Map<String, Object> context) {
super(parent);
setTitle(this, "Test Tab Sequence");
final ScrolledComposite scroll = new ScrolledComposite(this, SWT.BORDER
| SWT.V_SCROLL | SWT.H_SCROLL);
scroll.setLayout(new GridLayout(1, true));
final Composite main = new Composite(scroll, SWT.NONE);
GridLayout layout = new GridLayout(1, true);
layout.horizontalSpacing = 10;
layout.verticalSpacing = 10;
main.setLayout(layout);
Group grp = newGroup(main, "Texts");
addLabel("Text 1");
Text txt = new Text( grp, SWT.FILL|SWT.BORDER);
txt.setLayoutData( new GridData(100, SWT.FILL, false, true) );
addLabel("Text 2");
txt = new Text( grp, SWT.FILL|SWT.BORDER);
txt.setLayoutData( new GridData(100, SWT.FILL, false, true) );
Point size = grp.computeSize(SWT.DEFAULT, SWT.DEFAULT);
grp.setLayoutData(new GridData(size.x, size.y));
grp = newGroup(main,"Texts in Composites");
addLabel("Comp 1");
Composite comp = new Composite(grp, SWT.BORDER);
comp.setLayoutData( new GridData(100, SWT.FILL, false, true) );
comp.setLayout(new FillLayout());
new Text( comp, SWT.FILL);
addLabel("Comp 2");
comp = new Composite(grp, SWT.BORDER);
comp.setLayoutData( new GridData(100, SWT.FILL, false, true) );
comp.setLayout(new FillLayout());
new Text( comp, SWT.FILL);
size = grp.computeSize(SWT.DEFAULT, SWT.DEFAULT);
grp.setLayoutData(new GridData(size.x, size.y));
// for the previous controls the tabbing is working
// for the two controls below, the tab button has to be pressed twice to move to the next control
grp = newGroup(main, "MyInputs");
addLabel("MyInput 1");
(new MyInput(grp)).setLayoutData(new GridData(100, 20));
addLabel("MyInput 2");
(new MyInput(grp)).setLayoutData(new GridData(100, 20));
size = grp.computeSize(SWT.DEFAULT, SWT.DEFAULT);
grp.setLayoutData(new GridData(size.x, size.y));
scroll.setContent(main);
size = main.computeSize(SWT.DEFAULT, SWT.DEFAULT);
main.setLayoutData(new GridData(size.x, size.y));
main.setSize(size);
main.layout();
scroll.setExpandHorizontal(true);
scroll.setExpandVertical(true);
scroll.getParent().layout();
GridData scLayData = new GridData(SWT.FILL, SWT.FILL, true, true);
scroll.setLayoutData(scLayData);
scroll.setMinSize(main.computeSize(SWT.DEFAULT, SWT.DEFAULT));
scroll.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
scroll.setMinSize(main.computeSize(SWT.DEFAULT, SWT.DEFAULT));
}
});
scroll.getParent().layout();
this.getParent().layout();
}
private void addLabel(String text) {
Label label = new Label(this.currentGroup, SWT.SINGLE);
label.setText(text);
label.setAlignment(SWT.LEFT);
Point size = label.computeSize(SWT.DEFAULT, SWT.DEFAULT);
GridData data = new GridData(size.x, size.y);
label.setLayoutData(data);
}
private Group newGroup(Composite parent, String name) {
this.currentGroup = new Group(parent, SWT.SHADOW_IN);
// GridDataFactory.fillDefaults().applyTo(this.currentGroup);
this.currentGroup.setText(name);
this.currentGroup.setLayout(new GridLayout(2, false));
return this.currentGroup;
}
private class MyInput extends Composite {
private Control contr;
private MyInput(Composite parent) {
super(parent, SWT.BORDER);
contr = new Text(this, SWT.FILL);
}
}
|
|
| | |
Goto Forum:
Current Time: Sat Jan 18 12:03:47 GMT 2025
Powered by FUDForum. Page generated in 0.03256 seconds
|