12-10-2018 12:52 PM
I have a tree control with a few parent items, and a few children items. If a user double clicks on a parent or child I have a dialog come up. This is done by using the Double Click event on the event structure. What I'm finding is if the user double click on a parent's expand it also triggers that event. Is there a way to know that the user's mouse is over the expand/contract item so that I can do nothing if a double click occurs there? One option I can try is to keep track of how long ago a user last expanded/contracted and if a double click occurred soon after an expand/contract to do nothing. I figure this will work but was hoping for a more simple solution but didn't find one.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
Solved! Go to Solution.
12-10-2018 01:15 PM - edited 12-10-2018 01:19 PM
In the Item Close? and Item Open? events, there is a type property of Tree Double Click
You could possible check to make sure it's not that type.
I have not tested this.
12-10-2018 01:57 PM
If you don't have nested parents, you can check the coords of the mouse click. If the horizontal position of the mouse click minus the horizontal location of the tree is less than a certain value, don't show the dialog. This may not work for nested parents since the expand symbols are indented.
12-10-2018 02:03 PM
@Mancho00 wrote:
In the Item Close? and Item Open? events, there is a type property of Tree Double Click
You could possible check to make sure it's not that type.
Nope this "Type" is the type of event just generated so it will be either Item Close? or Item Open?.
@aputman wrote:
If you don't have nested parents, you can check the coords of the mouse click. If the horizontal position of the mouse click minus the horizontal location of the tree is less than a certain value, don't show the dialog. This may not work for nested parents since the expand symbols are indented.
Yeah I think this might have to be the route I go. I do have nested parents, but I can look at the Indent Level, and allow for more on more indented items. I'll try to come up with a demo of what I'm thinking with your tip.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
12-10-2018 02:07 PM
I also thought about using custom symbols and disable the expand/contract symbol. With this, you can put a Point to Row Column invoke node in the event and it will return if the event happened in the symbol. This would require other coding to manipulate the symbols.
12-10-2018 02:27 PM
@aputman wrote:
I also thought about using custom symbols and disable the expand/contract symbol. With this, you can put a Point to Row Column invoke node in the event and it will return if the event happened in the symbol. This would require other coding to manipulate the symbols.
This would also not work on trees where I want the symbols used for other things, unless I use multiple symbols and then that becomes a bigger issue.
Here is what I came up with which appears to work for my setup. I'm guessing pixel offsets will change with OS styles, LabVIEW fonts, and possibly phase of the moon.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
12-10-2018 07:23 PM - edited 12-10-2018 07:25 PM
This was a bit of a pain but I think I've got it, and you don't need to worry about pixel counts. Hopefully there aren't some edge cases I haven't considered... but the example works 🙂
I think this'll do it:
I tested the different events generated by both actions (double clicking an item versus an Expansion box), and noted the following:
-Double clicking the item name generates an O/C (Open or Close) event and a Tree Double Click event nearly simultaneously
-Double clicking the Expand button generates an O/C event immediately, and another O/C and Tree Double Click event about 150 ms later (the length of time between two clicks).
We therefore have 4 cases we need to handle with 4 different "event signatures":
-Case A: The user double clicks the Expand button. The list should rapidly expand and contract, and generate no popups. Events generated are an O/C event, then ~150 ms later, another O/C event and a Tree Double Click event simultaneously.
-Case B: The user double clicks a parent name. The list should not expand or contract, and a popup should show for the Parent item. Events generated are an OC event and a Tree Double Click event generated simultaneously.
-Case C: The user single clicks the Expand button. The menu should expand. Events generated are an OC event.
-Case 😧 The user double clicks a Child name. Only a Tree Double Click event is generated.
The key is the simultaneously generated events. During each O/C event, use a Flush Events function set to Tree Double Clicks. If any events are flushed, we know it was a simultaneous event, so we know we're in Case A or B. If no events are flushed, it was a regular Expand operation, so we're in Case C. Last, case D is handled with a regular Tree Double Click case.
A and B are discerned by the time since the last O/C event (note the use of a Feedback node, not a shift register, since we care only about the time since the last O/C event- not the last event.) If the time since the last O/C event is less than 500 ms (what Google says is a double-click), then we're in Case A, otherwise we're in Case B.
I hope that makes sense- my test code seems to work, hopefully there aren't any Gotchas when you put it into real use.
Edit: Forgot to mention one thing. The name of the User Event is important. If it's not Tag, then the Event Structure won't be able to give you any data in the Tree Double Click case, and you won't know *which* parent item was double clicked.
12-13-2018 09:34 PM
Here's my try. It kind of works, but it's buggy and I don't see what's wrong.
12-14-2018 08:36 AM
@BertMcMahan I think yours is my favorite so far. Still more overhead than I think should be there for something so simple but whatever. Yeah Paul yours got really buggy at a few points where I couldn't expand or collapse even clicking on the plus and minus a single time at one point. Thanks for playing.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
05-03-2019 03:37 AM
I'm a bit late to the party here, but just ran into the same issue. Turns out there is a Cell Part property returned in the tree's double-click event data, which indicates exactly which part of the tree control was double-clicked (this is in LV2018, not sure about earlier versions). Filtering on this did the trick for me.