strange problem with actions and focus.

Hello All,

I'm writing a small plugin for IDEA and discovered a strange problem. I have a ToolWindow, just like TODO one, with two tabs in it. Each tab includes a toolbar that was created using open API action manager. I've added a change listener to the JTabbedPane that requests focus for the certain component when JTabbedPane selected tab changes. After component.requestFocus() is called the toolbar in the selected tab stops working - my AnAction implementation actionPerformed() method is not called (however update() method is called).

The more or less same TODO window works in the same situation (its components inside tabs receives focus when active tab changes) and toolbars works fine.

Any ideas where the problem could be? I'm working with the build 929.

2 comments
Comment actions Permalink

Hello,

I've found solution to my problem. When one would like to focus certain control in the tool window (in my case - focus JTree control on JTabbedPane.stateChanged event), then just calling the tree.requestFocus() is not enough. Though it makes control focused, but actions created through the IDEA actions system and visible in the tool window (like toolbars) stops working.
The way that works is:


I think it's a bug (i.e. toolwindow should be activated when focus is granted to one of the controls inside it). What do you think, should I submit it?

0
Comment actions Permalink

Alexander Kitaev wrote:

Hello All,

I'm writing a small plugin for IDEA and discovered a strange problem. I have a ToolWindow, just like TODO one, with two tabs in it. Each tab includes a toolbar that was created using open API action manager. I've added a change listener to the JTabbedPane that requests focus for the certain component when JTabbedPane selected tab changes. After component.requestFocus() is called the toolbar in the selected tab stops working - my AnAction implementation actionPerformed() method is not called (however update() method is called).

The more or less same TODO window works in the same situation (its components inside tabs receives focus when active tab changes) and toolbars works fine.

Any ideas where the problem could be? I'm working with the build 929.


Do not use requestFocus at all. JTabbedPane awfully manages focus.
Requesting focus into some child component could request focus into
JTabbedPane itself. Actually ToolWindowManager requests focus into
necessary controls and activates tool windows by itself. If you want
manually manage focus then you have to activate tool window first and
perform any focus activity in the its "invokeLater" runnable.

With best regards,
Vladimir Kondratyev
_____________________
JetBrains

0

Please sign in to leave a comment.