Inside Eclipse Image Viewer plugin I want to add moving on arrow keys left <- or right -> to the next or previous image (in Fullsize mode)
QuickImageEditor
uses ToolBar
and ToolItem
.
ToolBar toolBar = new ToolBar(compos, SWT.FLAT);
toolBar.setLayoutData(toolbarData);
previous = new ToolItem(toolBar, SWT.FLAT);
previous.setToolTipText("Previous Image");
previous.setImage(new Image(parent.getDisplay(), iconsdir + "previous.gif"));
previous.setSelection(true);
While ToolItem
doesn't have API to add keylister, I add lister to ToolBar
.
added code is
toolBar.addKeyListener(new KeyListener(){
//@Override
public void keyPressed(KeyEvent e) {
}
//@Override
public void keyReleased(KeyEvent e) {
if (e.keyCode == SWT.ARROW_LEFT){
clickedPrevious();
return;
}
if (e.keyCode == SWT.ARROW_RIGHT){
clickedNext();
return;
}
}
});
This however does not work.
How to add keyboard-lead actions to Eclipse Editor?