Keyboard events, icepdf viewer
[Logo]
ICEsoft.org Forums: ICEfaces, ICEmobile, ICEpdf
[Search] Search   [Recent Topics] Recent Topics   [Groups] Home Page | www.icefaces.org  [Register] Register  [Login] Login 
Keyboard events, icepdf viewer  XML
Forum Index -> ICEpdf General
Author Message
sevkam

Joined: 07/06/2010 04:10:19
Messages: 8
Offline


Hello,

I'm trying for a while to catch keyboards event on the view, but can't find a way. I've added just the scrollpanel to my window, so I don't have any menu or toolbars... And then I add a keyListener to this scrollpane, or I modify the inputMap. But the keyPressed method of my listener is never executed.

I tought may be it was not the good object to add the listener, so I also tried with the documentView, but no success.

Code:
Container viewContainer = ((DocumentViewControllerImpl) iceController.getDocumentViewController()).getViewContainer();
 viewContainer.addKeyListener(keyListener);


or this way
Code:
AbstractDocumentView abstractDocumentView = (AbstractDocumentView) ((DocumentViewControllerImpl) iceController.getDocumentViewController()).getDocumentView();
 abstractDocumentView.addKeyListener(keyListener);


Does anyone have an idea ?
sevkam

Joined: 07/06/2010 04:10:19
Messages: 8
Offline


I found how to do, I needed to install the shortcut on the component inside the jscrollpane and not the jscrollpane itself. It only works with an inputMap though, not with a keyListener

It works this way :

Code:
JScrollPane jScrollPane = (JScrollPane) iceController.getDocumentViewController().getViewContainer();
 JComponent vue = (JComponent) jScrollPane.getViewport().getComponent(0);
 String printKey = "imprimer";
 KeyStroke raccourciImprimer = KeyStroke.getKeyStroke('P',
 InputEvent.CTRL_DOWN_MASK);
 InputMap inputMap = vue.getInputMap(JPanel.WHEN_IN_FOCUSED_WINDOW);
 inputMap.put(raccourciImprimer, printKey);
 ActionMap actionMap = vue.getActionMap();
 actionMap.put(printKey, new AbstractAction() {
       public void actionPerformed(ActionEvent e) {
 	//do what you want
       }
 });
 
Forum Index -> ICEpdf General
Go to:   
Powered by JForum 2.1.7ice © JForum Team