LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

listbox value change on right click with runtime menu

Solved!
Go to solution

Hi all,

 

Using LV 2012...

 

I have a multi-column listbox containing a single column of text values.  I am trying to set up the following functionality:

 

Right-clicking on an item will cause a runtime menu to open...  user will select "Parameters" from the menu and a dialog containing parameters specific to the item will appear.

 

The runtime menu was easy.  The problem is the listbox value (row) does not change with right-clicking alone.  I currently have to left-click to change the value and then right-click for the menu.  Any way to to change the value with right-clicking?

 

Thank you!

Charlie

 

 

0 Kudos
Message 1 of 5
(3,442 Views)
Solution
Accepted by topic author asuwish4

Rather than changing the value, you can do something like this - use the Mouse Down? event for the listbox. Because it's a filter event, it should execute first (although you might need to place it at an earlier frame in the event structure). Use the coords from that event and call the Point to Row Column method on the listbox. This will give you the row, which you can now keep in a shift register. Don't discard the event, and this will cause the menu event to occur, where you can now use the row value from before.


___________________
Try to take over the world!
Message 2 of 5
(3,420 Views)

Thank you!

 

I had tried this originally with the difference being that I was trying to filter for button = 1 to see if I would get the right mouse button instead of the left.

 

I also had the filter state after the user runtime state.  I didn't know order made a difference.

 

Finally, to really improve the GUI feel, I had the returned ROW value write to the listbox VALUE of a property node in the filter state instead of writing it in the user runtime state.  This is because the highlighting of the row wasn't changing right away.

 

Now as soon as you right click, the highlighting reflects the current row, and then the parameter dialog pops up.

 

Awesome solution.  Thank you!

 

Charlie

 

 

Message 3 of 5
(3,410 Views)

 

Here is the final..  just to be complete.  Smiley Wink

 

 

Capture.PNG

 

-=Charlie=-

Message 4 of 5
(3,400 Views)

asuwish4 wrote:

I also had the filter state after the user runtime state.  I didn't know order made a difference.


I'm not 100% sure that it does. As far as I know the cases in a case structure are checked in order until a match is found, and I seem to remember something about the same thing happening with event structures, but without proper documentation, it would just be an implementation detail.

 

I'm assuming some code can be written to check what the order is, but I never really had the need to do it. I am assuming that filter events, at least, are handled first regardless of where they are, but I haven't actually checked.


___________________
Try to take over the world!
0 Kudos
Message 5 of 5
(3,387 Views)