LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I add mouse-drag functionality?

A friend of mine asked me for help. He is building a program to look at a
grid of 100 components. He has a 2D array of on/off buttons that control
which components the program will look at. He would like to make it easier
for the user to select which of the 100 he wants to check so he'd like to be
able to choose sets of buttons using left-click and drag. Any ideas?
0 Kudos
Message 1 of 3
(2,594 Views)
You could have an array of 10x10 Booleans with a transparent picture control
over them. The picture control allows you to get the mouse pointer
coordinates and the mouse button state. With this information you can
implement the drag-select scheme you describe.

There is no simple way of doing this as far as I'm aware.

Adam Russell wrote in message
news:tjp3lrntmfgi48@corp.supernews.com...
> A friend of mine asked me for help. He is building a program to look at a
> grid of 100 components. He has a 2D array of on/off buttons that control
> which components the program will look at. He would like to make it
easier
> for the user to select which of the 100 he wants to check so he'd like to
be
> able to choose sets of buttons using left-click a
nd drag. Any ideas?
>
>
0 Kudos
Message 2 of 3
(2,594 Views)
A very interesting problem indeed.

As pointed out by Craig, a solution for you can be to use a transparent picture control over your array of buttons. That is how I would have done this too. Because to handle 100 buttons without this drag function will be difficult and take long time for the user.

The implementation of a drag a function might at first seem tricky, but in fact it is rather straightforward. The key is to extract the mouse position when the mouse button was pressed and later released and to convert these two positions to coordinates of the buttons affected. With the powerful library of functions in LabVIEW this can be done easily.

I attach a simple example to show how it works. I decided to use a 2D array of 10x10 elements (like yours) and I
added a feature that draws a rectangle during the drag operation. What is inside the selected area will be inverted which allows for both selecting and unselecting. My main program is named Select100.vi and it is calling InvertButtons.vi that changes the 2D array according to the mouse coordinates when the user drags the mouse over an area.

I hope this helps and good luck in helping your friend with his program.

/Mikael
Download All
Message 3 of 3
(2,594 Views)