From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programmatically initiate cursor drag

Solved!
Go to solution

Using a Mouse-Down Event on a graph with no cursor , you create a new cursor at that location.  Since you want to complete the dragging action of the new cursor in that Mouse-Down Event instance, how can you initiate cursor drag without a Mouse-Up and then Mouse-Down?  One click - That's All.

 

Thanks Folks...

0 Kudos
Message 1 of 10
(3,237 Views)

HLB,

 

Could you clarify a little bit more of what you're trying to do here?  Are you trying to highlight a part of the graph?  Also one click of the mouse will trigger two events, both a mouse-down event and a mouse up event when you release.

------------------------------------------------------------------------------------------

Jon F.
Technical Support Engineer
National Instruments
0 Kudos
Message 2 of 10
(3,177 Views)

Is this a question or a statement?  You appear to be answering a question that wasn't asked.

 

Kelly Bersch
Certified LabVIEW Developer
Kudos are always welcome
Message 3 of 10
(3,161 Views)

Hello Jon,

 

What I want to do is create a new cursor at the location of the mouse-down event and drag that cursor.  To activate the mouse down event I would have to click on the graph.  Without letting my mouse button up, since I would then be executing code in the mouse-down event and I would also be at the desired location on my graph, I would execute code to programmatically create a new cursor and then use the mouse to drag that cursor to snap to a new data point on the graph.  The other options might be to click on the graph which would create the cursor, let the mouse button up and click again on the newly created cursor and then drag it.  That method would require more clicks and I would have to exclude the other events generated in the process.  I think more desirable would be a one-click, that’s-all approach, but to do that I would have to make the mouse associate itself with the new cursor as if it had just clicked on an existing cursor, and thus be in drag mode.  So this would require some slight of original intent of the LabVIEW source code.  Can you think of any way to hook back in to the drag function on the graph programmatically?

 

Thanks,

HLB

0 Kudos
Message 4 of 10
(3,144 Views)

Hello Kelly,

 

The answer is yes, it is.  Beware of asking questions that you might not want to know the answer to.  Ha!

 

Thanks,

HLB

0 Kudos
Message 5 of 10
(3,140 Views)

HLB,

 

I do not think that what you want to do will be possible with one mouse click.  I believe you would have to use multiple events to get the functionality you want and that would get a little complicated to implement for such a small thing as showing cursors.  Is there any reason that you don't want the cursor to begin with?  You can select to show cursor on the graph and it will always be there without any event cases.

------------------------------------------------------------------------------------------

Jon F.
Technical Support Engineer
National Instruments
0 Kudos
Message 6 of 10
(3,120 Views)

http://digital.ni.com/public.nsf/allkb/280875F12A53D4FD8625699E006F0BBA

 

This may help as well...

------------------------------------------------------------------------------------------

Jon F.
Technical Support Engineer
National Instruments
0 Kudos
Message 7 of 10
(3,114 Views)

Hello Jon,

 

Currently I am running with two mouse clicks.  It would be more intuative with one.  The graph is cluttered enough without a cursor hanging around when you don't need it.  The need for the cursor is to use its snap_to_data capability when adding an annotation to a data point.  I could use an already existing cursor but postion it outside of the graph axis range, or change its style to a single small point and or color to match background (though that can leave a color hole in your other colored data, grids and annotations).  It would be easier if It had a Value(Signaling) property that would re-click it programmatically.

 

Thanks,

HLB

0 Kudos
Message 8 of 10
(3,105 Views)

HLB,

 

After thinking a little about this, it may be possible with some event cases.  The first would be creating the cursor on a 'mouse down' event.  On another event case, you could use the 'mouse move' event to update the x position of the cursor (you stated to want the y value to snap to graph, this would be set when creating the cursor).  You would just have to make sure the cursor exists before you run code inside the 'mouse move' event to update cursor position.  You could add a T/F case structure inside the mouse move event to verify that there is a cursor in the cursor list before trying to update the position of it.  Then use a 'mouse up' event to stop updating position.

 

I'm not sure if this will work or not but it's about all I could think of.

 

 

------------------------------------------------------------------------------------------

Jon F.
Technical Support Engineer
National Instruments
0 Kudos
Message 9 of 10
(3,076 Views)
Solution
Accepted by topic author HLB

Hello Jon,

 

I will try impementing the dueling events you speak of, when I get a chance, and see it that does it.  Sounds like it might work.  Mouse-Down creates cursor, Mouse-Move updates the snapped_to_data cursor to the mouse position, resident code keeps track of cursor and lable position while user drags cursor around and it snaps to new points, Mouse-Up reads final position.

 

Thanks,
HLB

0 Kudos
Message 10 of 10
(3,042 Views)