10-24-2013 07:26 PM
TL;DR: does anyone know if it would be possible to put flattened data in the "ItemTags" of a control's shortcut menu? Is there any reason why one couldn't get away with that?
Had a crazy idea recently:
Let's say I have a FP indicator that displays some information about an object. The class has a "FormatForDisplay()" method that formats the class private data into a string to write to a string indicator. Now, depending on the class, I may have several different operations that I could do on that class. So I'm thinking I would have a "PopulateShortcutMenu()" dynamic dispatch; when the user right-clicks on the string indicator, i'll call that method for the object that has been formatted for the display (assume that I am able to track what object I have used to populate the indicator).
The action to be triggered by the shortcut menu selection itself is an object (a message class) different from the class of object being displayed. What I'm wondering is, can I have the "PopulateShortcutMenu()" method insert a flattened object into the ItemTag, with a meaningful mnemonic for the ItemName, and then in the ShortcutMenu Selection event case, unflatten the ItemTag back into the object that was created?
It's a roundabout way to do things, yes. And maybe it would be better to just have a dynamic-dispatch UI for each class, and the UI would have specific actions and not have to deal with this weirdness. But still, it got me thinking....
Anybody tried something like that before? Are there any practical limitations to what you can put in the ItemTags of a shortcut menu (max size? printable characters only? etc)?
10-25-2013 03:03 AM
Whenever I hear of something like this (using an existing area to encode extra data), my first thought is to use a tag, which allows you to attach custom data to any control. I don't know if the tag methods are visible if you enable scripting, but there should be a couple of VIs in <vi.lib>\utility\usertags. Of course, you could also just use any other means of data transfer, like a FGV, but this should work more like what you want, because the data is kept in the control and the reference should be accessible from the event terminals.
10-25-2013 03:20 AM - edited 10-25-2013 03:22 AM