Mousereleased not firing

I'm working on a plugin that inserts a component into the text editor component (this part of the code from Adam Scarr)

JPanel outerPanel = (JPanel)editor.getComponent();
BorderLayout outerLayout = (BorderLayout)outerPanel.getLayout();
JLayeredPane pane = (JLayeredPane)outerLayout.getLayoutComponent(BorderLayout.CENTER);
JPanel panel = (JPanel)pane.getComponent(1);
BorderLayout innerLayout = (BorderLayout)panel.getLayout();

// Ok we finally found the actual editor layout. Now make sure we haven't already injected into this editor.
(innerLayout.getLayoutComponent(BorderLayout.LINE_END) == null) {

    CodeOutlinePanel outlinePanel = new CodeOutlinePanel(plugin, ((TextEditor) editor).getEditor());
    outlinePanel.setPreferredSize(new Dimension(110,0));
    panel.add(outlinePanel, BorderLayout.LINE_END);
    panels.put(editor, outlinePanel);
} else {
    logger.debug("I07: Injection skipped. Looks like we have already injected something here.");

Later I add a mouse listener to the CodeOutlinePanel panel. This mouse listener gets MousePressed events for button 1, 2, and 3. It also gets MouseReleased events for button 1 and 2. Strangely, I'm not getting MouseRleased events for button 3!

I've tried consuming the coorisponding MousePressed event but that doesn't help.

I also tired adding a global AWTEvent listener to see if the window even gets the events, but it doesn't! Is IDEA doing something funny like attaching native code that might be consuming the middle click on this component?

How do I get the MouseReleased events for button 3 (middle mouse button)?


Comment actions Permalink

No, IDEA does nothing funny that would eat specifically the middle mouse button released events. This looks like either an AWT issue or a problem with the mouse driver.

Comment actions Permalink

Actions bound to mouse clicks are triggered on mouse release event. Middle mouse click is bound to 'Goto to Declaration' action in default keymap, so on mouse release event that action might be triggering and consume the event. You can try to remove corresponding action binding in keymap settings and see whether that changes the situation.

Comment actions Permalink

The AWTEvent listener appears to catch every single event coming into the window regardless if it was caught. In this case, it's not showing the middle mouse up on at least the editor. I was able to reproduce the missing mouse up event on the project file list box when the last list item was selected (or maybe it was the other way around, I don't recal).

Comment actions Permalink

IDEA uses its own implementation of EventQueue. That implementation, in particular, launches actions bound to mouse clicks and doesn't follow default dispatch path if the action has been triggered. So listeners registered via Toolkit.addAWTEventListener won't be invoked in that case.


Please sign in to leave a comment.