There are two DefaultSingleCDockable in my control, is there any way to let the focus travel between the DefaultSingleCDockable when I type Tab ?
Sorry for the late answer, I was not reading the forum.
Hm, that is a tricky question. Especially since “tab” already has a meaning.
One possible solution could be to map “tab” to the DockableSelector:
control.putProperty( DockableSelector.INIT_SELECTION, KeyStroke.getKeyStroke( KeyEvent.VK_TAB, 0 ) );```
The selector is a little dialog where the user can select another Dockable with the arrow keys.
*** Edit ***
Or maybe just adding a KeyboardListener, catching events, and calling "toFront" on the next Dockable is enough. The defintion of "next Dockable" is up to you...
``` final CControl control = ...
control.addKeyboardListener( new CKeyboardListener() {
@Override
public boolean keyTyped( CDockable source, KeyEvent event ) {
return false;
}
@Override
public boolean keyReleased( CDockable source, KeyEvent event ) {
if(event.getKeyCode() == KeyEvent.VK_TAB){
int index = control.getRegister().getDockables().indexOf( source );
index += 1;
index %= control.getRegister().getDockableCount();
CDockable next = control.getRegister().getDockable( index );
if(next instanceof AbstractCDockable){
((AbstractCDockable)next).toFront();
}
return true;
}
return false;
}
@Override
public boolean keyPressed( CDockable source, KeyEvent event ) {
return false;
}
} );