C++ Builder 6 Different Popup menu on Items and Subitems of a TreeView and No Popup on empty area - popup

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.

Related

Use same keyEquivalent in NSPopupButton menu as in Main menu

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.

How do I set a variable in separate widget class from custom button widget class in ue4 blueprint

attached are my current blueprints. i have a widget that is the level select screen, which will contain instances of a level select button. depending on which button is clicked, i want it to update a variable in the level select widget which stores the level from that particular button. I'm trying to do this so that i can add or remove levels from the selector in a modular way, as well as because there will be an option to select multiple levels played one after the other.
https://i.gyazo.com/71731a6682b186b0e1b874a80144677c.png is the button code, when clicked it will take the editor value as an int, and (when working properly) send that to the level select code which is pictured here https://i.gyazo.com/277e54770aa1a70bdab083f8b98aa714.png, selecting the proper level based on the value of variable 'selected level' when the 'proceed' button is clicked.

Creating a set of buttons with oncick events on them

I have an array of objects in my game, and I want to create buttons in the UI, based on object count in array. In menu construction script, array is scanned for objects, and for each of them button is created, and labeled by object name.
Now I want to do onclick event for these buttons which will display info about respective object in the UI. So I need to somehow create a onclick event for each of appearing buttons, or create universal onclick event for this group of buttons, which will read object name from button and search for that in the array. Is it possible to create events for objects which are going to appear during game? Please suggest.
Workaround - by onclick event get buttons array and find which is hovered by mouse ATM
you could make a widget object containig the button with the onclick event, then in the contruction script you create the widgets.
Here you can find some documentation for widgets:
https://docs.unrealengine.com/en-US/Engine/UMG/UserGuide/WidgetBlueprints/index.html
https://docs.unrealengine.com/en-US/Engine/UMG/UserGuide/CreatingWidgets/index.html

Auto complete a dropdown menu in a cq5 dialog based on input from a previous dialog field

My custom CQ5 component has a dialog which consists of 2 drop down menus. I would like to automatically set a default value to second menu depending on whatever is the value selected from the previous drop down.
How can I achieve this?
you can register handlers for different events triggered by the widgets. You can use the "selectionchanged" event to register a function that will read the new content from the dropdown and then use the setValue() method in the second dropdown to put whatever you want there.
To obtain the second dropdown from the first you can use the nextSibling() method.
The widget documentation will help you a lot. look for "selection"

Programatically change icon for a eclipse RCP command

I have a menu drop down action in the coolbar. It has 3 sub items that form a radio group. I would like to change the icon shown in the coolbar when the user selects one of these options.
I've googled and seen that I should look at:
org.eclipse.ui.commands.ICommandService.refreshElements(String, Map)
and
org.eclipse.ui.commands.IElementUpdater
Its probably the right thing to look at exception its not enough information. One or two small code snippets will be excellent.
Thanks in advance.
Ok basically if you don't want to use a "custom" control the what to do it is to have your handler (handler that is linked to the specific command) implement IElementUpdater. When every the toolbar item gets shown or clicked on (i.e if the user selects on the the radio buttons) the method: updateElement(UIElement element, Map parameters) gets called.
The element has a setIcon() method and this is what i used to change the icon of the menu drop down action.
Every update to the Coolbar points to the specialization of the WorkbenchWindowControlContribution class.
This bug 186800 has some code example in it which can be of interest.