LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Listbox Behavioe

I want a custom listbox behavior:

  1. A single click toggles the selection of an item.
  2. A double click does something else*, without changing the selection.

The attached code works, but it's ugly and sluggish.  How can I make it cleaner and faster?

 

* In my example, it just beeps.

0 Kudos
Message 1 of 14
(359 Views)

Hi Paul,

 

Why don't you use the DoubleClick item in the Event data?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 14
(332 Views)

@GerdW wrote:

Hi Paul,

 

Why don't you use the DoubleClick item in the Event data?


Gee, I didn't even know about that; and I didn't poke around well enough to find it (D'oh!).

Message 3 of 14
(272 Views)

There is also a double-click event:

 

altenbach_0-1747066799189.png

 

0 Kudos
Message 4 of 14
(244 Views)

@altenbach wrote:

There is also a double-click event:

 

altenbach_0-1747066799189.png

 


Yes, but it happens after the Value Change event (and I don't want the value to change on a double-click).

0 Kudos
Message 5 of 14
(218 Views)

@GerdW wrote:

Hi Paul,

 

Why don't you use the DoubleClick item in the Event data?


That gets me slightly cleaner, but no faster.  On a double-click, both clicks come through and I have to inhibit the 1st one if there's a 2nd one.

0 Kudos
Message 6 of 14
(210 Views)

@paul_a_cardinale wrote:

@GerdW wrote:

Hi Paul,

 

Why don't you use the DoubleClick item in the Event data?


That gets me slightly cleaner, but no faster.  On a double-click, both clicks come through and I have to inhibit the 1st one if there's a 2nd one.


Using the Mods Double Click and changing your timeout to 100ms seems to work for me without noticeable lag.

0 Kudos
Message 7 of 14
(198 Views)

The DoubleClick item in the Event data does not help you as it is always preceeded by the first click event and you cannot filter that out (at least not without having to recreate the value change behaviour that you do want) without knowing up front that there is a secondary click on its way...

 

Generally it is a bad idea to modify standard behaviours like this though. People have expectations based on the standards and breaking with those makes the interface non-intuitive. Is what you try to achieve really so unique that it justifies breaking with the standard behaviour? If the intent is to first let the user select multiple items and then e.g. get a view related to all those items when you double click I would either assign that to a separate button below or next to the list, or add a right-click menu item for it instead.

0 Kudos
Message 8 of 14
(189 Views)

@paul_a_cardinale wrote:

I want a custom listbox behavior:

  1. A single click toggles the selection of an item.
  2. A double click does something else*, without changing the selection.

The attached code works, but it's ugly and sluggish.  How can I make it cleaner and faster?

 

* In my example, it just beeps.


An alternative (that might need different user instructions) would be to do ctrl+click to toggle an item (that's the default behavior, no code needed) and do an alt-click to do "something else".

0 Kudos
Message 9 of 14
(168 Views)

I hate the default behavior for multiple selection.  If you inadvertently let up a little bit on the key, all the selections that you've made so far are cleared.

0 Kudos
Message 10 of 14
(151 Views)