I have an NSPopUpButton that has a few menu items that expose identical functionality to some main menu items. Those are actions most relevant to the users current context.
To signal that those items also have keyEquivalents (shortcuts), I wanted to set their keyEquivalents to the same keys as the items in the main menu.
Unfortunately that doesn't seem to work, since the conflicting items now have their keyEquivalents removed in the main menu (presumably automatically by AppKit).
Is it somehow possible to show the same keyEquivalent in the NSPopUpButton menu?
Normally context menus are not the most logical place to show shortcut info. However, if you really want this, then the best / probably only working option is to reuse the menu in the main menu that you want to show in your NSPopUpButton, like this:
myPopUpButton.menu = (NSApp.delegate as! AppDelegate).myMenu
In this example, myMenu is an #IBOutlet to one of the NSMenu items of the application main menu.
If you want to show a slightly different menu in your popup, then you can implement menuWillOpen of the NSMenuDelegate to dynamically hide or add menu items.
Related
My aim is to create a tabbed menubar instead of the traditional menubar presented in the latest TinyMCE 4.7.6. I plan to do this by hiding the menubar, then create a toolbar above the normal toolbar. This new toolbar would consist of buttons with the menu names such as File, Edit, Insert, View etc. When one of these buttons is clicked, the normal toolbar buttons would be replaced with the toolbar buttons under the relevant menu item. [I hope I have been clear to this point.]
In case I haven't worded my description well enough, I want to create something like the Microsoft Word 2013 menu style.
Here's my problem. I am unable to create the toolbar that would host the menu buttons (File, Edit etc buttons). The TinyMCE docs say nothing about creating custom toolbars. All there is, is on creating toolbar buttons and adding them to an existing toolbar. Anyone with an idea how this can be done? Thanks.
This is quite some work you want to do, so first of all let me tell you a "ribbon" skin is already existing, check it here
Now if you really want to make your own, first you have to understand the difference between a menubar and a toolbar
On this image there is one menubar and two toolbars
Here is the documentation for the menubar API and for the toolbar this is here
But you should really give a try to the existing skin first.
I am using Nattable in my application. I have built a context menu which popups on right click on any row in the nattable.Now I would like to add sub menu items for one of the menu item in the context menu. Is it possible to add sub menus into context menu in Nattable ?
This is how I have constructed context menu,
Creating context menu using PopupMenuBuilder class and Binding context menu into Nattable by extending AbstractUiBindingConfiguration class.
Thanks in Advance! :)
There is no build-in support for sub-menus. But as you basically create the menus programmatically by using the AbstractUiBindingConfiguration you can also programmatically add the sub-menu items this way. Typically by using the SWT.CASCADE style bit on the MenuItem and setting a Menu to that MenuItem.
Creating sub-menus programmatically is shown in this SWT Snippet
I want to have different popup menu on Items and SubItems and NO Popup menu on empty area of a TTreeView is that possible ?
I want something like the pictures bellow
There are two ways you can do that.
Create 2 separate TPopupMenu objects with the desired menu items, do not assign either one of them to the TreeView's PopupMenu property, and then use the TreeView's OnContextMenu event to call the Popup() method of whichever TPopupMenu you need based on which node the user is clicking on.
Create 1 TPopupMenu object and put both menu items in it, and assign it to the TreeView's PopupMenu property, then use the TPopupMenu.OnPopup event to show/hide the menu items based on which node the user is clicking on.
In either case, you can use the TTreeView.GetNodeAt() method to determine which node is located at the coordinates of a mouse click, if any.
I want to hide the toolbar item or whole toolbar when I m in specific perspective .
Till now I have tried to define a perspective extension and inside it i defined all the menubar and toolbar item needed to be hidden and linked them with the respective id.But contrary to my expectation when i opened the application all the menu item are gone as expected but toolbar item are still visible.Is there anything which I am doing wrong here.
2nd approach :
WorkbenchWindow window = (WorkbenchWindow) PlatformUI.getWorkbench()
.getActiveWorkbenchWindow();
window.setCoolBarVisible(b.getSelection());
// window.toggleToolbarVisibility();
But here as window is an internal class so I donot want to use this approach.
Any light on my first approach is appreciated ..
How can I modify a GWT menu - grey out some entries, put a checkmark next to others, according to my application state?
My app has a menu bar across the top - File, Edit, View, Insert, Format, etc. I have a number of paragraphs, each of which could have a different format. When the user clicks on Format, I want the format menu to show a checkmark next to the menuItem that corresponds to the format of the currently selected paragraph. If some formats are inappropriate for the currently selected paragraph, I want to grey those menuItems out.
The main issue is when to do the update: (a) when the Format menu button is clicked, or (b) each time my user selects a new paragraph?
I find option (a) more appealing. But how can I detect this? A MenuItem doesn't have any facility for adding event listeners. It could be a mouseClick that I need, but it might be a mouseOver: if the user clicks on the Insert menuItem the Insert menu will appear, but then if the mouse is moved over Format, then the Format menu will appear.
Option (b) sounds simpler, but wastes more processor time.
For my contextMenu (right click on the paragraph), it's much easier, because the menu is only constructed when the right click happens.
I've resorted to using the square-root symbol (√) for a tick. Does anyone know a nicer way? Do I need to use HTML and use " Plain-Format" for my menu item?
Finally, is there a way to disable (grey-out) a menu item so that it can't be selected?
Option (a) sounds better from a conserving resources point of view.
Instead of using the square-root symbol, why don't you use an image (using the com.google.gwt.user.client.ui.Image class)?
I think a more elegant/simple solution might be to use the checkbox class for your menu items. That way you could have automatic ticks/checks instead of having to use an image or the square-root symbol. Also, you will be able to "grey-out" items with setEnabled(false). Otherwise, you will have to write your own widget or add your own functionality to your menu labels in order to "grey-out" items.