Jump to content

Bad behavior with tree control


Recommended Posts

I have been trying to understand what's going on with my tree control and I'd like to share this with the community to see if somebody has seen this behavior before. Maybe there is something obvious that I am not seeing...

 

I attached the VI (LV2011) with instructions inside (will take you 20s to perform the experiment, I dismantled the VI to its bare minimum). Please don't comment on the overall architecture (state machine...) since I modified the VI just for the sake of posting it here and removed all advanced features.

 

Long story short, after programmatically modifying the value of the tree, I modify its value a second time by clicking directly on one of the tree items. I then expect the NewVal value given through the left node of the value change event case to match the value of the tree terminal. Depending on the code that first modified the value programmatically, sometimes this expectation is met and sometimes it isn't. Run the code, it's easier to understand that way...

 

Thanks for your feedback!

Tree value issue.vi

Link to comment

If you turn on execution highlighting, you can see what happens here. You have an item selected in the tree control, based on typing in the combobox. Then, you click on a different item in the tree. That click enqueues two events: 1) a value change event for the combobox, and 2) a value change event for the tree. They execute in that order. The value change event for the combobox sets the selected tree item to the item that corresponds to the combobox value. Then, the tree control value change event is executed. The NewVal is the value of the tree when the event occurred (when you clicked on the tree), but the terminal value is the value set through the property node in the combobox value changed event.

Link to comment

Perfect analysis.

 

I fixed the issue by putting a case structure in the combobox value change event. I only perform the code that updates the value of the tree if the combobox has the keyfocus. This disables the selection through the dropdown of the combobox, but in my actual application I hide the dropdown button anyway.

 

Thanks ned  :worshippy:

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.