Jump to content

MCLB movable column separators and header click events.

Recommended Posts

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...



Link to comment

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?

Link to comment

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:



Link to comment

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 by ShaunR
  • Like 2
Link to comment

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.

Link to comment

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?

Link to comment

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 by John Lokanis
Link to comment

Join the conversation


Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.


×   Your previous content has been restored.   Clear editor


  • Create New...

Important Information
