Java – how to display the drop-down menu of a command after clicking the command icon?

In the eclipse RCP application, I have a custom view and provide a drop-down command in the toolbar of the view:

<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 several other commands to contribute to the command1 drop-down menu, as shown below:

<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>

So far, everything has been normal. I can see the command1 icon on the view toolbar. When I click the drop-down symbol next to it, the menu will display command2 and command3 commands - as expected

Question:

What I want to achieve now is to display 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 toolbar of eclipse.)

I think I need to programmatically trigger the display of the command1 drop-down menu from the command1 handler, but I can't find any examples of how to do this

Thank you for your help!

Solution

I just asked the same question on the eclipse RCP forum and got an immediate answer The trick is to trigger a false event that will trigger the menu display. Here are the details:

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

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>