[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Re: Context menu position

Markus Gieser schrieb:
Hi All!

I hope that the SWT newsgroup ist the right place for my problem:

I have a SWT Table in a Eclipse property tab / section. Now I'm trying to show a context menu on that table.

So I have a composite and added a table on it:
table = this.getWidgetFactory().createTable(parent, SWT.FULL_SELECTION | SWT.MULTI);


Then I added a menu on the table and some menu items to the menu:
tableMenu = new Menu(table);

MenuItem addItem = new MenuItem(tableMenu, SWT.POP_UP);

...

Additionally I already found an article describing the fact that the mouse position the MouseEvent returns is relative to the composite the menu belongs to (so the table in my case). So I found the following "algorithm" to get the absolute mouse position:


Why are you showing the menu with a mouse-listener? Normally you simply do table.setMenu(tableMenu) and it is shown by the OS. If you want an abstraction you should take a look at MenuManager coming from JFace.


Tom

--
B e s t S o l u t i o n . at
--------------------------------------------------------------------
Tom Schindl                                          JFace-Committer
--------------------------------------------------------------------