Is possible to add MenuItem
(or second Menu
) on the right side of the application window (as on image below)?
3 Answers
A partial answer to your questions is that a second menu bar cannot be added. Reference here.
Every shell can optionally display a single menu bar using the setMenuBar(Menu menuBar) method of Shell. It's possible to create many menu bars in a shell, but only one can be visible in a shell at a time.
Perhaps you can try creating a second shell window that hovers over the location where you want your second (right-aligned) menu. You will need to ensure that this shell always remains attached to that particular corner of the window. You might have problems if the size of the main shell is reduced, which might show one menu overlapping the other. Not a nice solution though. Perhaps use a toolbar instead with a filler (SWT#SEPARATOR_FILL
) item?
-
-
Well the RCP implementation adds to the toolbar through that extension point, which is easily possible with SWT (using Toolbar) so I didn't feel there was a need to look further into the implementation. Commented Dec 26, 2012 at 11:26
If you are using org.eclipse.ui.menus
extension point, you can put toolbar:org.eclipse.ui.trim.command2
as the locationURI
(see this answer for a list of other locations).
-
-
-
1If something works with Eclipse RCP, which is SWT based, then there would definitely be a way to achieve this in SWT. It would be good to look at some code to see how Eclipse RCP achieves this. Commented Dec 24, 2012 at 14:58
-
Using the location URI presented in this answer will create a toolbar item, not something on the main menu bar, right? Commented Dec 24, 2012 at 15:24
It seems there isn't an obvious way to do this. You can specify either left to right or right to left orientation, but not both. Also, there is no any filling element which can be put between menu items, as it is in Swing.
-
-
Well, I just went through Eclipse documentation, so this is my reference.– tcbCommented Dec 24, 2012 at 11:09