0

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.

https://github.com/Nodeclipse/quickimage/blob/master/quickimage/src/nu/psnet/quickimage/editors/QuickImageEditor.java#L118-128

    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?

Community
  • 1
  • 1
Paul Verest
  • 60,022
  • 51
  • 208
  • 332
  • In plugins you usually use key bindings (`org.eclipse.ui.bindings` extension point) for commands to set up keys. – greg-449 Mar 03 '15 at 10:27
  • Yes, but that would require to define Actions, that I am not good at. I thought I could do without that. – Paul Verest Mar 03 '15 at 10:30
  • Actually was looking at https://github.com/culmat/eExplorer/blob/master/com.github.culmat.eexplorer.plugin/src/com/github/culmat/eexplorer/views/ExplorerView.java example – Paul Verest Mar 03 '15 at 10:31

0 Answers0