Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display the command's drop-down menu after the command icon is clicked?

In Eclipse RCP application I have a custom view and a drop-down command contributed into that view's toolbar:

  <menuContribution
        allPopups="false"
        locationURI="toolbar:test.ui.views.MyView">
     <command
           commandId="test.ui.commands.Command1"
           icon="icons/Command1.png"
           id="test.ui.commands.Command1.dropdown"
           label="Command 1"
           style="pulldown">
     </command>
  </menuContribution>

Then, I have a couple of other commands contributed into the Command1 drop-down menu like this:

  <menuContribution
        allPopups="false"
        locationURI="menu:test.ui.commands.Command1.dropdown">
     <command
           commandId="test.ui.commands.Command2"
           label="Command 2"
           style="push">
     </command>
     <command
           commandId="test.ui.commands.Command3"
           label="Command 3"
           style="push">
     </command>
  </menuContribution>

Until now everything works fine, I can see the Command1 icon on the view's toolbar and when I click the drop-down symbol next to it, the menu shows up with the Command2 and Command3 commands - as expected.

Problem:

What I would like to achieve now is to show the drop-down menu not only after the user clicks the drop-down symbol next to the Command1 icon, but also after the user clicks the Command1 icon itself.

(for example, this is how the Open Console command works in the Console view's toolbar in Eclipse)

I guess I need to programmatically trigger displaying the Command1 drop-down menu from within the Command1 handler but I couldn't find any examples on how to do that.

Thanks in advance for any help!

like image 687
bacza Avatar asked Oct 22 '22 08:10

bacza


1 Answers

I just asked the same question on Eclipse RCP forum and got immediate answer. The trick is to fire a fake event that will trigger the menu to display, here are the details:

http://www.eclipse.org/forums/index.php/t/488692/

like image 113
bacza Avatar answered Nov 01 '22 08:11

bacza