08-29-2012 06:53 AM
I was trying to improve the functionality of my code, when i realized this. so, i am positng my thought here, for your feedback.
i have an application where the GUI has a tree control and some right click menu options (short cut menu (user)). when the user wants to perform a right click menu selection for a specific item tag in the tree control, one would have to first left click on the item and then right click on it to activate the correct menu.
unless the user selects a item tag, by the left click event, i cannot detect which sort cut menus are valid for the same.
example: i have a tree with 2 parent tags and 3 children each. the right click menus are different for parents and children. so different operations that cold be performed on each.
now, my customer asked me, why he needs two clicks. like in windows explorer, where he could select a file by right click on it in, he wants to know if i could provide the same feature.
for now, i explained to him that i cannot provide such a feature as i do not know if it is possible in LabVIEW.
Like i can select an excel file by right clicking on it, can we have LabVIEW do the same? Is such a feature already available in LV 2012? ( i am using LV 2010)
If not, is this idea already posted or can i post it to the LV Idea Exchange?
i want to detect the item tag on which the right click event occurred and perform the operation accordingly. i will not need a value change event and then a short cut menu selection event. i can do with one event.
i hope my explanation is clear.
Thank you for your thoughts.
08-29-2012 07:49 AM - edited 08-29-2012 07:58 AM
You could use the current mouse position to determine the location within the tree control. This wouldn't be easy if the tree control contents changed a lot.
Here is a thread where someone used a transparent picture control to map coordinates on a graph. http://forums.ni.com/t5/LabVIEW/How-do-you-map-a-mouse-events-coordinates-to-the-coordinates-of/m-p/...
08-29-2012 08:40 AM
You don't really need to go that far. In your Mouse Down event, use the Point to Row Column method to get the item that the mouse has been clicked on. If this is valid, you can then wire the "tag" output of this method to the "Value" property node, and that will select the tree item. You can then display the appropriate menu item at the same time. Make sure the tree selection mode is set to "1 item".
08-29-2012 11:17 PM
@smercurio_fc wrote:
You don't really need to go that far. In your Mouse Down event, use the Point to Row Column method to get the item that the mouse has been clicked on. If this is valid, you can then wire the "tag" output of this method to the "Value" property node, and that will select the tree item. You can then display the appropriate menu item at the same time. Make sure the tree selection mode is set to "1 item".
hi
I like your idea better. i looked around yesterday for the mouse events. i checked the outputs from the mouse down events but did not realise that i could make use of it this way.
however, i would still end up processing two events -> mouse down and then right click menu selection event.
i ll play around with this idea today and check if its acceptable.
i still want to know if this feature could be implemented in future versions of labview. is it feasible?
08-30-2012 12:34 AM
Ok..on experimenting, i found something else... we do not need a mouse down event...
we can still do what "smercurio_fc" suggested, with either "shortcut menu activation" notify or filter event as well..
as i would anyways need the filter event to get the menu reference and disable certain menu items depending on the tag selected, i could use the invoke node in the same event and get the tag name and the column where the right click occurred.
thank you for the replies.
08-30-2012 07:29 AM
While your shortcut menu activation method will display the menu, it will not select the tree menu item, and you had specifically indicated in your original post that this was a requirement since your customers were complaining that they had to click twice. That's why I suggested writing to the "Value" property node, as this selects the menu item. Of course, you could do it in the shortcut menu activation event as well.
08-30-2012 07:35 AM - edited 08-30-2012 07:36 AM
Yes! i forgot to put that in the sample vi which i uploaded. that was only to show that i managed to use your idea for the shortcut menu activation event too.
however, i included the value property node in my actual code.
thank you
11-15-2012 12:36 PM
How were you able to individualize context menus for tree items? I am trying to do that right now and anytime I change the context menu of a tree item it changes it for every tree item.
Thanks!