LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Disable Double Click Behavior on Tree Expand

Solved!
Go to solution

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.

0 Kudos
Message 1 of 15
(4,987 Views)

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.

0 Kudos
Message 2 of 15
(4,974 Views)

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. 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
Message 3 of 15
(4,954 Views)

@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.

0 Kudos
Message 4 of 15
(4,948 Views)

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. 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 5 of 15
(4,945 Views)

@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.

 

Tree Example Double Click_BD.png

0 Kudos
Message 6 of 15
(4,930 Views)
Solution
Accepted by topic author Hooovahh

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:

 No expand on parent double click.png

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.

Message 7 of 15
(4,904 Views)

Here's my try.  It kind of works, but it's buggy and I don't see what's wrong.

 

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 8 of 15
(4,865 Views)

@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.

0 Kudos
Message 9 of 15
(4,849 Views)

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.




Certified LabVIEW Architect
Unless otherwise stated, all code snippets and examples provided
by me are "as is", and are free to use and modify without attribution.
Message 10 of 15
(4,455 Views)