John Lokanis Posted November 10, 2014 Report Share Posted November 10, 2014 I am stumped. I created a MCLB that allows you to sort the data based on the column the user clicks on. This is pretty simple. Just trap the mouse down event and check if it is in the header row. If so, find the column clicked and sort the data, then discard the event. But then I wanted to add the ability to resize the columns however this did not work because the event would get discarded after doing the sort. So I stopped discarding the events. But now I end up sorting the data every time I try to resize a column. So, I need some way to detect if I am hovering over a column separator and have the resize cursor displayed and then use this fact to suppress the sort on mouse down events. Any idea how to solve this? Is it even possible? thanks for any insights... -John Quote Link to comment
ShaunR Posted November 10, 2014 Report Share Posted November 10, 2014 Handle the resizing in "Mouse Move" rather than mouse down and use the Point to Row Column property node to get whether you are in the header or not. Quote Link to comment
John Lokanis Posted November 10, 2014 Author Report Share Posted November 10, 2014 Just to be clear, I am using the "Mouse Down?" event to perform the sort. I do not have custom code to implement the resize. That is provided by the MCLB control. So, if I was to use the mouse move, how would I accomplish that? The act of clicking anywhere on the control triggers the "Mouse Down?" event and the sort runs if the mouse is in the header. I need to suppress this if I am doing a resize. If I use "Mouse Move" that will trigger every time the mouse changes position over the control regardless of clicking. How could I isolate that to suppress the sort while still allowing the click of the header to trigger the sort? Quote Link to comment
Darren Posted November 10, 2014 Report Share Posted November 10, 2014 I had this exact issue when I added column sorting to the Project Find dialog in LabVIEW 2013. It's cheesy, but the way I handled it was to store off the column widths of the columns on both sides of the mouse down whenever the Mouse Down event occurred: And then on Mouse Up, if I found that the column widths were different, I conclude that it's a column resize, and I don't do the sort: Quote Link to comment
ThomasGutzler Posted November 10, 2014 Report Share Posted November 10, 2014 Use Mouse up for sort and check if you've done a resize since the last mouse down Quote Link to comment
John Lokanis Posted November 10, 2014 Author Report Share Posted November 10, 2014 Well if that is the best solution you could find, I doubt I will be able to do better. I actually thought about this but really hoped there was a more elegant way to do this. Thanks for confirming this solution. I'll give it a whirl. Quote Link to comment
Darren Posted November 10, 2014 Report Share Posted November 10, 2014 No problem...it also gave me a chance to plug the fact that the column headers in the Project Find dialog are clickable for sorting in LabVIEW 2013 and later! Quote Link to comment
hooovahh Posted November 10, 2014 Report Share Posted November 10, 2014 What about reading the mouse pointer? If it is a ][ or what ever symbol then don't discard, and don't sort. Quote Link to comment
ShaunR Posted November 10, 2014 Report Share Posted November 10, 2014 (edited) sort or not.vi Measuring column widths seems a bit overkill if you are not auto fitting. A point of reference. A single click to sort is not usually a desired operation especially for sorts that can take some time because it's just too easy to accidentally set it off. A double click to toggle is IMO more desirable. Edited November 10, 2014 by ShaunR 2 Quote Link to comment
AlexA Posted November 11, 2014 Report Share Posted November 11, 2014 Shaun I have to disagree, the standard Window's interaction is single click to sort, it's what's intuitive to most people so if the expectation isn't met I think it becomes a minor user gripe. Quote Link to comment
John Lokanis Posted November 12, 2014 Author Report Share Posted November 12, 2014 Thanks for the example. The mouse move to 'disarm' the sort between a mouse down and mouse up did the trick. Quote Link to comment
Darren Posted November 12, 2014 Report Share Posted November 12, 2014 The mouse move to 'disarm' the sort between a mouse down and mouse up did the trick. Yeah, that is a simpler way to do it, I didn't think of that. The only thing to consider is that if the user is a little sloppy with his mouse (i.e. moves it a pixel or two between mouse down and mouse up), the sort won't trigger. Probably not a big deal, but something to keep in mind. Quote Link to comment
John Lokanis Posted November 12, 2014 Author Report Share Posted November 12, 2014 Agreed, but when I tried it in practice, it seemed acceptable. Now if I could just get mouse leave events to consistently fire before mouse enter events for adjacent controls, I would be a happy camper... Quote Link to comment
Darren Posted November 12, 2014 Report Share Posted November 12, 2014 Now if I could just get mouse leave events to consistently fire before mouse enter events for adjacent controls, I would be a happy camper... Assuming both of these controls have the same owner, if you're seeing Mouse Enter before Mouse Leave, that sounds like a bug. Can you post a VI that demonstrates the issue? Quote Link to comment
John Lokanis Posted November 12, 2014 Author Report Share Posted November 12, 2014 (edited) Well, they are in separate panes but on the same front panel. And one is an Xctrl. It seems to only happen when leaving the Xctrl and entering the MCLB in the adjacent pane. I will have to build an example when I have some time. The app where this is happening is way to big to post. (Now I've thread-jacked my own thread!) Edited November 12, 2014 by John Lokanis Quote Link to comment
Darren Posted November 12, 2014 Report Share Posted November 12, 2014 I will have to build an example when I have some time. The app where this is happening is way to big to post. Ok, when you get around to it, you can either PM me the example, or post it to forums.ni.com for an AE to take care of. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.