0

I have created a tool bar with few Tool bar items in my Application.

Menu:

  <extension point="org.eclipse.ui.menus">
       <menuContribution locationURI="toolbar:main">
           <command
              commandId="com.test.myapp.ui.commands.TestCommand"
              style="push"
              tooltip="My Tool Items 1">
           </command>

Command configuration:

    <extension point="org.eclipse.ui.commands">
        <command
                    defaultHandler="com.test.myapp.ui.commands.TestCommand"
                    helpContextId="test"
                    id="com.test.myapp.ui.commands.TestCommand"
                    name="Open Test View">
              </command>

Below is my TestCommand class.

    public class TestCommand extends AbstractHandler{
        //Overridden the execute method here....
    }

So now if I click on my Tool bar this will execute my Command class. I would like to know how can I add mouse listener to this Tool bar item so that we can do some stuff when mouse over on the tool bar item (Ex:Mouse over to tool bar item, it generally shows tool tip, So now if I press some key it should open some other page for this. So to do that if I can get the control of this event I can add some stuff to it)

greg-449
  • 109,219
  • 232
  • 102
  • 145
rcpsgr
  • 1
  • You could use a MouseTrackListener to get the position of the cursor on your ToolBar and then use `ToolItem.getBounds()` to get the positions of your toolitems. This example should do, what you want to achieve: http://www.java2s.com/Code/Java/SWT-JFace-Eclipse/HowtoimplementhoverhelpfeedbackusingtheMouseTrackListener.htm – Calon Jul 28 '14 at 07:25
  • Hi Calon, Thanks for your reply. your suggestion can help if we are creating the tool bar our own by usinsg ToolBar bar = new ToolBar(frame, SWT.BORDER);. but in my case I'm not doing this. I'm creating tool bar using the extension point as shown below. . So please suggest if any way we can get the control of these Toolbar Items when we create the these through extension points. – rcpsgr Aug 01 '14 at 11:34

0 Answers0