Coding Tips (JavaScript/CSS/VBA/Win32)

Useful code snippets, tips and some Windows applications

SWT Tips

How To Add A Listener for Tab Out Events

Use a TraverseListener class. Example:


TraverseListener traverseListener = new TraverseListener () {
	public void keyTraversed (TraverseEvent e) {
		if ( e.detail == SWT.TRAVERSE_TAB_NEXT){
			System.out.println("traverse");
		}
		if (e.detail == SWT.TRAVERSE_ESCAPE)
			System.out.println("traverse escape");
		}
};

someField.addTraverseListener(traverseListener);
		

Make a control span 2 columns in a 2 column GridLayout

Suppose, you have a 2 column GridLayout example, and you need one control to occupy the whole available width, like the combo box at the following example:

Use horizontalSpan property of the GridData class and set it at 2. Example:

	GridData data = new GridData ();
	data.horizontalAlignment = GridData.FILL;
	data.horizontalSpan =2;