12-14-2015 12:43 PM
Is there a way to get the current mouse cursor? I know there is a function for changing it, but I want to know what it currently is.
The reason for this is because I have a multicolumn listbox. And on Mouse Up I have code that detects what column you clicked on and sort on that column. But I also allow for adjusting the column width. The problem is if you adjust the width this is also registered as a Mouse Up and will sort the column, when the user didn't want to do that.
My simple solution was to look at the current mouse cursor, and if it was the one that is used for adjusting the column size, on the Mouse Up, then just ignore the event. Any thoughts? Thanks.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
Solved! Go to Solution.
12-14-2015 01:20 PM - edited 12-14-2015 01:20 PM
Presumably the Point to Row Col only gives you the row-col cluster, but you can add up the column widths to figure out if the click was on a border.
12-14-2015 01:56 PM
Well I don't like this solution because of the extra code, and edge cases associated with it. The Point to Row returns if you are in bounds, the row and column, and if you are in the symbol. If I am in the first column header it reutrns row -1 column 0, if I have my cursor on the separator (and my mouse has the separator icon) it still returns -1 0. So this function doesn't return to me any more information other than the cell I'm in.
I could use this to then say get the position and size of the cell, then see if my mouse is in that space, minus a few pixels. That is this code
One problem I have with this is I don't know if the MCLB has moveable column separators turn on or not. Seems that property isn't exposed, and after a quick search I find this thread...made my me where I was complaining about this missing feature. Why am I forced to continually rediscover LabVIEW limitations?
http://forums.ni.com/t5/LabVIEW/Moveable-Column-Seperators-Property/td-p/2217334
Since I am eventually making this into an XControl, I can add my own Allow Moveable Separators property, where if false it will set the mouse cursor back, and discard mouse downs on the separator, then use the code above to determine where the mouse click was. I guess this is better than trying to read the cursor image, but I did find this in that thread which shows a way to do that, it just doesn't work, but does try to answer the original question. I'll play around with it and see if I can get it to work.
https://decibel.ni.com/content/docs/DOC-15261
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
12-14-2015 02:06 PM
@Hooovahh wrote:
and after a quick search I find this thread...made my me where I was complaining about this missing feature.
http://forums.ni.com/t5/LabVIEW/Moveable-Column-Seperators-Property/td-p/2217334
Well, at least I'm consistent...
12-14-2015 02:42 PM
It looks like in windows for me my cursor starts at icon=1. I don't know if this is the default cursor when hovering a listbox though. If it is, you can set the cursor to icon 1, then set it back, and compare the cursor IDs. If they are the same, then you must have already been using the default cursor.
12-14-2015 02:48 PM
Nevermind, I tested with a listbox and it seems like it's always set to icon=0 even when resizing 😞
12-14-2015 02:50 PM
Have you tried the Get Clicked Column Header method for MCLB? It returns a -2 when resizing the column headers
12-14-2015 03:12 PM - edited 12-14-2015 03:13 PM
@aputman wrote:
Have you tried the Get Clicked Column Header method for MCLB? It returns a -2 when resizing the column headers
Man, why did you have to go and make it all simple? I tested several things and I'm still going to post them for completeness but I found two other, inferior ways of doing this task. Still useful information in those methods, just not as good for this one case.
I found two ways to get the icon of the cursor. One is using the .Net method linked to earlier. The code could use some work and there was some functions being repeated twice but it got an image of the cursor along with a few other things. I also found an AutoIt3 function that returns the selected cursor so I turned that into an EXE and embedded it in the VI. I then wrote code to speed test these two methods and the one shown earlier. The result was that the AutoIt version was the slowest at around 30ms, .Net was and LabVIEW native was about the same at 20ms or less. But none of that really matters unless you want to know the cursor image which in my case I did, because I didn't know there was an easier way to know if the header was clicked. In any case the code is posted showing how to get the mouse cursor as an image, or as text using these methods. Thanks everyone.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
12-14-2015 03:20 PM
My bad.
12-14-2015 03:24 PM - edited 12-14-2015 03:29 PM
GRRRRAHHHH...turns out this invoke node doesn't work right when in an XControl...which was the goal of all of this. I need to do some more testing but it appears this function always returns a -2 when in an XControl. If I can make a simple example I'll make a new thread.
Edit: it must be something else I'm doing the simple test works.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord