Can I programmatically close a context menu in jsTree? - jstree

Is there a way I can programatically close a context menu in jsTree? I implemented a way to open the context menus on hover using show_contextmenu but I need to close it when the mouse leaves

Ok, looking through the code I found what I needed, there is a property called hide_on_mouseleave which I just set to true in the source and it started working as expected.
If that doesn't work, this is the code used to close the context menu executed when hide_on_mouseleave property is true:
$.vakata.context.hide();

Related

How do I disable the object definition window in VS Code?

In VS Code, if I Ctl+click or press F12 on an object defined elsewhere in the file, the focus is moved to that object, but additionally a window opens up showing me exactly what I'm already trying to look at except in a smaller window than I would normally be viewing the object definition. If I instead press Alt+F12, this object definition window opens without moving my focus to the object.
In the case of pressing Alt+F12, this functionality could potentially be useful since it saves me from having to navigate from the code I'm working with. However, in the case of Ctl+click or F12, both navigating away from the code I'm working with and displaying the object definition in a smaller window is not helpful and I want to disable it.
Here is an image of what I'm trying to describe when using Ctl+click or F12:
How do I disable this? I would prefer to only disable the functionality that both shows the window and navigates away, but would settle for disabling showing the window entirely.
This issue has been addressed in version 1.26.1 of VS Code.

How to highlight MenuItem programmatically in SWT

I open a context menu programmatically. Now additionally I would like to highlight the first menu entry.
This highlighting happens when I move with the mouse over the context menu or press the arrow keys on the keyboard. I am interested how I can trigger this programmatically.
I know the API of MenuItem does not offer this feature out of the box. So I tried to fire some MouseEvents of the type MouseOver and MouseHover, but without any success.
Has anybody an idea how to implement this feature?
I am not sure if you can change menuitem highlight colors, I haven't seen any previous example before. Look at this though: Change eclipse menuitem color
If you want to simulate what the user does and if you happen to know the location of the menu item, you can use Display#setCursorLocation() to position the mouse pointer over the menu item.
Note however, that if and how a menu item is highlighted is platform specific.
You should not use this method other than for demonstration of test purposes. If your application needs to highlight or preselect an entry in a list of choices,
you should probably use another widget. If you more describe your use case, we may be able to find a suitable widget.

tinyMce function to determine if popup is already open

With tinyMce, I've got onclick code to open a plugin using this:
ed.windowManager.open(...)
Right now, it will open a 2nd, 3rd, etc. instance of this plugin window each time I click the target.
Instead, I want the onclick code to ignore the click if the window is already open. How can I detect the open window.
Here's the solution I'm going with:
I seem to have confirmed:
-- that windowManager.open() does not return a reference to the window the same way that window.open() does
-- windowManager does not have a built-in way to limit the number of instances that can be opened.
But it does have a way to add an onClose function to the plugin window:
ed.windowManager.onClose.add(function() {alert('Closing!');});
So I'll be using a variable in the onClick code to keep track of whether the popup window has been opened and closed. The onClose function will mark that variable as closed

How to make GraphicalEditorWithFlyoutPalette's PaletteView visible on first start

My GEF editor (extending GraphicalEditorWithFlyoutPalette) always opens the editor with the palette hidden on first start of the application / first opening of the editor (after a build for example).
As this will potentially bewilder users who'll need to go in search of the flyout icon first, I'd like to have the palette view shown whenever the editor is opened. The user can then choose to close it on his/her preferences.
How can I achieve this? The API doesn't seem to give any clues, or I'm unable to find them...
The state of the palette defines if it is open or closed. This state is accessible using the getPalettePreferences().setPaletteState() method that is accessible in the GraphicalEditorWithFlyoutPalette. To open the palette, you must set it to the FlyoutPaletteComposite.STATE_PINNED_OPEN, like this:
getPalettePreferences().setPaletteState(FlyoutPaletteComposite.STATE_PINNED_OPEN);
If you want to ALWAYS override the state so that the palette is always opened with the editor, you have to add the line to the constructor of your editor. If you only want to do this once, and then leave the state as it was last selected by the user... No idea how to do this :-(

Adding menu listener for Paste option in SWT Browser

I have a org.eclipse.swt.browser.Browser instance created in a composite. I would like to know when some content is pasted in the browser using the (platform specific) right click context menu and selecting the paste option.
In the menuDetected() of MenuDetectListener, I get a notification when the context menu is detected in the browser.
How can I know if the Paste option is selected from the context menu?
Regards,
Noopur
No you can't access the selected context menu item. There is no direct provision for that. At least not in eclipse 3.7. Although, you could try different combinations of events for determining the menu item. For example, in windows the internet explorer populates the status bar with 'inserts the clipboard...' when your mouse pointer hovers over the Paste menu item, you can capture this using StatusTextListener event.
Note: The hack is not an elegant solution, even if you get it working, there is still some possibility that it may break with new or older releases of SWT or in fact its behavior may vary with operating systems !!