Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
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
Clemens Gantert is currently offline Clemens GantertFriend
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);

		}
	}
Re: Tab sequence does not work properly for custom composite widgets extending Composite [message #1802508 is a reply to message #1802492] Mon, 11 February 2019 09:02 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2327
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi Clemens,
without additional explanation :) please set SWT.NO_FOCUS flag to your MyInput custom widget like:
---
private class MyInput extends Composite {
Control contr;
priprivate vate MyInput(Composite parent) {
super(parent, SWT.BORDER|SWT.NO_FOCUS);
contr = new Text(this, SWT.FILL);
}
}
---
Best regards,
Ivan
Re: Tab sequence does not work properly for custom composite widgets extending Composite [message #1802542 is a reply to message #1802508] Mon, 11 February 2019 17:20 Go to previous message
Clemens Gantert is currently offline Clemens GantertFriend
Messages: 6
Registered: August 2012
Location: CA, USA
Junior Member
Oh, no! This was exactly it. I spent so much time on this and it was something so simple! I even saw the property but did not try it.
Thanks, Ivan, for the quick response.

Cheers,
Clemens
Previous Topic:RAP 2.3: Close a RAP application session and redirect to another page
Next Topic:How to stop blank screen appearing when switching between screens
Goto Forum:
  


Current Time: Mon Dec 09 15:25:31 GMT 2019

Powered by FUDForum. Page generated in 0.02047 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top