Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Buttons in setTabList do no accept focus(Buttons in setTabList do no accept focus)
Buttons in setTabList do no accept focus [message #1297466] Tue, 15 April 2014 17:52 Go to next message
Pete DeLine is currently offline Pete DeLine
Messages: 5
Registered: April 2014
Junior Member
I have a Shell displaying three Buttons. I've created a Control array containing each button and used it to call shell.setTabList. For some reason, none of the buttons will receive focus as I attempt to tab between them. I've tried adding a FocusListener and a KeyListener to each one but that didn't help. The code is below. Thanks in advance for any help.
package com.example.swt.widgets;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class TabExample {
  public static void main( String[] args ) {
    Display display = Display.getDefault();
    Shell shell = new Shell( display );
    shell.setLayout( new RowLayout() );
    Button b1 = new Button( shell, SWT.PUSH );
    b1.setText( "Button1" );
    Button b2 = new Button( shell, SWT.PUSH );
    b2.setText( "Button2" );
    Button b3 = new Button( shell, SWT.PUSH );
    b3.setText( "Button3" );

    Control[] controls = new Control[] { b2, b1, b3 };
    shell.setTabList( controls );
    shell.pack();
    shell.open();
    while( !shell.isDisposed() ) {
      if ( !display.readAndDispatch() ) {
        display.sleep();
      }
    }
    display.dispose();
  }
}

[Updated on: Tue, 15 April 2014 17:52]

Report message to a moderator

Re: Buttons in setTabList do no accept focus [message #1300331 is a reply to message #1297466] Thu, 17 April 2014 13:55 Go to previous messageGo to next message
Niraj Modi is currently offline Niraj Modi
Messages: 17
Registered: November 2013
Junior Member
Hi Pete,
Tried your code snippet, tab behavior works fine for me with latest SWT4.4M6 build on Windows7.
Re: Buttons in setTabList do no accept focus [message #1302828 is a reply to message #1300331] Sat, 19 April 2014 00:05 Go to previous messageGo to next message
Pete DeLine is currently offline Pete DeLine
Messages: 5
Registered: April 2014
Junior Member
Hi Niraj -

Thanks for your response. This appears to be an issue in OSX. I was also able to run the snippet on Windows using SWT 4.3. No such luck on the Mac though.
Re: Buttons in setTabList do no accept focus [message #1391674 is a reply to message #1302828] Tue, 01 July 2014 08:32 Go to previous message
Tomas R. is currently offline Tomas R.
Messages: 7
Registered: July 2009
Junior Member
On the Mac, default setting is that user can use Tab to move keyboard focus between text boxes and lists only. It is system-wide setting and SWT honors it.

To use Tab to move focus between all controls see System Preferences > Keyboard > Keyboard Shortcuts and for Full Keyboard Access select the 'All controls' option.
Alternatively there is a default key-binding for switching this setting: Control+F7.

Your snippet works Wink

[Updated on: Tue, 01 July 2014 08:35]

Report message to a moderator

Previous Topic:Developing 32bit SWT application on 64bit Linux
Next Topic:MouseAdapter behaving differently in Mac OS X
Goto Forum:
  


Current Time: Sat Oct 25 14:32:52 GMT 2014

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

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