Run-Time Shortcut Menu

Here we are going to discuss about creating run-time shortcut menu for a control programmatically. As a continuation to one of my previous posts, the control that we will consider here will again be a multicolumn listbox. We will see how to create a runtime shortcut menu and then insert the selected menu item into the corresponding cell as shown below.

RTSCM FP

To get started with, follow the instructions as shown below.

  1. Place a Multicolumn Listbox control on the front panel and initialize it as required.Ini-MCLB
  2. In the block diagram, place an event structure inside the while loop.
  3. Create a Shortcut Menu Activation? event for Multicolumn Listbox control. This is a filter type event which will be generated when the user right-clicks on the control to display the shortcut menu.
  4. To delete the default shortcut menu items, place a Delete Menu Items function.
  5. Use Insert Menu Items function to add menu items of your choice. In case of single menu item, connect a string constant to item names input. In case of multiple menu items, connect a string array constant to item names input. Also connect the menu reference input as shown below.RTSCMEvent
  6. Next to insert the selected menu item into the cell of multicolumn listbox, create a Shortcut Menu Selection?(User) event for Multicolumn Listbox control.
  7. Obtain the selected menu item from Item Tag event data field.
  8. Obtain the cell position(row,column) using the invoke node and insert the menu item into the corresponding cell as shown below.Insert-MCLB

Leave a Reply