LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

getting value of MCL post-change

I am using a dynamic event registration node to register an array of references to my multi column listbox.  

However, the dynamic event registration node is limited, and doesn't let you choose (for instance) Edit Cell as an event to trigger on.  Inside the event structure, I use a Point to Row Column function to determine where the user clicked, then I make the cell they clicked on the Edit Position so they can enter a value.  I want to write the value they enter out to a subroutine.  

 

This partially works.  The event triggers on the mouse down event of the user clicking, which is what I want so that they can edit the cell when they click on it.  But the problem is that my code samples the value at the time they click and writes it out, before they've entered their new value.  In other words, right now it only works if they click to enter a value, then click within the same cell after they're done, thereby triggering the event structure again and causing their new value to be written.

 

mcl_lv.png

 

Basically, I only want to write a new value to the subroutine (not shown, but the wire below the "val to write" comment on the far right goes straight to it) if they enter a new value (although it's not a big deal if it writes it even when they keep the value the same).  In other words, it's like I want it to 'wait' after they have clicked to edit a cell for them to either press enter or click outside of the cell, and then write the value they entered.  What's the best way to handle that while using dynamic event reg?

0 Kudos
Message 1 of 6
(2,595 Views)

What is the user interface you're trying to build? Does the user ever select a row, or you're just using it as a way for the user to enter values into a table? If you're using it as a table, it might be better to replace it with a table control. Then the whole problem goes away.

 

There might be other approaches to the interface you want as well. For example, instead of directly editing the MCLB, when the user clicks, move an off-screen numeric (or string) control over that location and set the focus to it. When you get a value change event on that control, you have your new value, which you then copy to the appropriate cell in the MCLB and pass to the function. I provided some example code that does this (although using a table instead of a listbox) here: http://forums.ni.com/t5/LabVIEW/array-of-cluster/m-p/1822451#M625032 If you use this as a starting point, note that dynamic event handling changed a bit in LabVIEW 2012 or 2013, so you might have to make some changes to get tabbing to work properly.

0 Kudos
Message 2 of 6
(2,573 Views)

The table is an interesting idea.  I am investigating it...what method would I use though?  For a Multicolumn Listbox, there's an associated event called Edit Cell.  What is the equivalent method for a Table?  I see a method called Set Cell Value, but that expects me to hardcode a value or control to that field, whereas what I want is for the user to be able to simply click in a cell and type a new value directly.

0 Kudos
Message 3 of 6
(2,541 Views)
You don't need a method at all. Make it a table control and set the cells to be editable (I think it's a right-click menu option but I'm posting from mobile and don't have LabVIEW available to check right now). You might find you have to click twice, or click in exactly the right spot, to make an edit, but give it a try.
0 Kudos
Message 4 of 6
(2,532 Views)

ok, I think I'm closing in on a solution.  Actually, it looks like a table is edit-able by default, so there's no need to make it editable (unlike an MCL).

 

So it looks like one way to accomplish what I want is to have an event structure that runs when the value of the table changes, as this event will trigger if a user enters a new value.  However, what I don't see is a way to determine what cell they changed the value of.  If I was triggering based on a mouse down event, then I could convert the coordinates to a row/column value...but the value change event doesn't give me access to that info.  Right now the only way I can think of is to compare the OldVal with NewVal and see what changed...but I feel certain there's a better way.

 

Short version - if I have a value change event structure triggered by a table edit, how do I determine what cell changed value?

 

thanks or the help

0 Kudos
Message 5 of 6
(2,523 Views)
0 Kudos
Message 6 of 6
(2,518 Views)