Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » e(fx)clipse » ContextMenu not showing
ContextMenu not showing [message #1782865] Fri, 02 March 2018 16:29 Go to next message
Alexander Kerner is currently offline Alexander KernerFriend
Messages: 25
Registered: January 2015
Junior Member
I have a TableView and would like to show a Context Menu when right-clicking.

I do as follows:

final ContextMenu cm = new ContextMenu();
cm.getItems().add(new MenuItem("bu"));
table.setContextMenu(cm);


For a "vanilla" FXApplication it works as expected. When I try the same in an e4 context, the Context Menu does not show up.

The View/Part class looks like this:

public class ViewTable {

	@Inject
	protected Composite parent;
	private FXCanvas fxCanvas;

	public ViewOrphanPeaksTable() {
	};

	@PostConstruct
	public void createControl() {
		init(parent);
	}

	protected void init(final Composite parent) {
		// this will initialize the FX Toolkit
		fxCanvas = new FXCanvas(parent, SWT.NONE);
		Platform.setImplicitExit(false);
		Platform.runLater(() -> createScene(parent));
	}
	@Focus
	public void setFocus() {
		fxCanvas.setFocus();
	}
}

Re: ContextMenu not showing [message #1783225 is a reply to message #1782865] Fri, 09 March 2018 11:39 Go to previous messageGo to next message
Alexander Kerner is currently offline Alexander KernerFriend
Messages: 25
Registered: January 2015
Junior Member
Anyone using FX context menus together with an e4 view part?
Re: ContextMenu not showing [message #1783227 is a reply to message #1783225] Fri, 09 March 2018 12:23 Go to previous messageGo to next message
Alexander Kerner is currently offline Alexander KernerFriend
Messages: 25
Registered: January 2015
Junior Member
I found a workaround.

fxCanvas.addMenuDetectListener(l -> {
    System.err.println("Hey there!");
});


Is a MenuDetectListener the intended way to show a context menu?

[Updated on: Fri, 09 March 2018 13:26]

Report message to a moderator

Re: ContextMenu not showing [message #1784503 is a reply to message #1783227] Wed, 28 March 2018 19:01 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
No for sure it is not. What OS are we a talking about?
Re: ContextMenu not showing [message #1786539 is a reply to message #1784503] Sun, 06 May 2018 19:10 Go to previous messageGo to next message
Alexander Kerner is currently offline Alexander KernerFriend
Messages: 25
Registered: January 2015
Junior Member
Linux, GTK3.
Re: ContextMenu not showing [message #1786547 is a reply to message #1786539] Mon, 07 May 2018 07:04 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
I think I've already seen this problem - just to make sure bringing up the context-menu (without your hack) using the the keyboard shortcut does work right?
Re: ContextMenu not showing [message #1787436 is a reply to message #1786547] Fri, 25 May 2018 10:19 Go to previous message
Alexander Kerner is currently offline Alexander KernerFriend
Messages: 25
Registered: January 2015
Junior Member
Never tried that. How do I assign a key combination to a context menu?

cm.setAccelerator(KeyCombination.keyCombination("Ctrl+O"));

does not work.
Previous Topic:Prototype of SceneBuilder integrated into Eclipse
Next Topic:How to embed JavaFX into an Eclipse rcp plugin ?
Goto Forum:
  


Current Time: Fri Apr 19 08:58:55 GMT 2024

Powered by FUDForum. Page generated in 0.02887 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top