9

Is possible to add MenuItem (or second Menu) on the right side of the application window (as on image below)?

enter image description here

1
  • Very interested in an answer for simple SWT, no RCP.
    – Baz
    Commented Dec 23, 2012 at 18:07

3 Answers 3

1
+50

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?

2
  • Just out of curiosity: Did you check the RCP implementation?
    – Baz
    Commented Dec 24, 2012 at 18:29
  • 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
0

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

4
  • But that only works if you are using Eclipse RCP, doesn't it?
    – Baz
    Commented Dec 12, 2012 at 15:39
  • @Baz Yes, only in this case. Commented Dec 12, 2012 at 15:49
  • 1
    If 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
0

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.

2
  • Do you know of any reference that confirms this?
    – Baz
    Commented Dec 24, 2012 at 10:05
  • Well, I just went through Eclipse documentation, so this is my reference.
    – tcb
    Commented Dec 24, 2012 at 11:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.