I'm trying to customize the right-click menu that appears for a tree control.
Mostly it works fine but I would like to add an underline and keyboard shortcut for commonly used items.
E.g. So that Edit appears as Edit, and if you press 'e' on the keyboard it fires the shortcut menu selection event for edit.
It only seems to work for application menus not right-click menus.
Am I missing something or is this a limitation / bug / oversight?
Unfortunatelly, adding an underline in shortcut menu (right-click menu editor) is not yet implemented in LabVIEW 2011, still you can post your idea at Idea Exchange here and our R&D will take a look at your proposal:
But there is a walkaround for implementing keyboard shorcuts for shortcut menu:
- Create the template Producer/Consumer Design Pattern (Events), and create tree control, who has element "Item" in the shortcut menu
- Add 2 events cases in the producer loop - Shortcut Menu Selection (user) for a tree control, and Key Down from <This VI>:
- In Shortcut Menu Selection (user) case you need to enqueue the ItemTag from Event Data Node
- In Key Down case you need detect the key combination you want to use and enqueue the tag of a item (Item in our case) from shortcut menu you want to call - this will connect keyboard combination with shortcut menu (In Event Data Node you have data Char, which return ASCII code of the pressed key; and PlatMods/Mods cluster, which include pressed modifiers as Ctrl, Alt, Command etc. )
- In the Consumer loop you need to make a case structure, which decide the action based on the dequeued item
If you will have any problems with implementation, or have any other question, feel free to ask.
Thank you for your reply.
Yes I did think about doing it that way but it seems a bit too convoluted.
I also don't like the idea of the Key Down event triggering on every key press.
I even started to think if there was some way to dynamically register for a key down event when the right-click menu was activated and then deregister afterwards.
But stopped before going too far down that path because it seemed to convoluted for what should be built in.
I think a suggestion in the idea exchange is the only practical option.