Listbox.CellBackgroundPaint not firing during DragOver?

I am working on a project that will be for both Mac (Cocoa) and Windows. In one window, I have two listboxes. The user may drag and drop between them (to establish a “link” between a pair of rows, one in each listbox).

I want to give the user feedback as to which row in the destination listbox s/he is over during the drag. In the DragOver event, I calculate which row the mouse is over, save that listindex in a window property (actually two properties, one for each listbox), and then invalidate the listbox. (I’ve also tried refresh with the same result.) In the CellBackgroundPaint event of each listbox, I check to see if the row being painted is the same as the row being dragged over, and if it is, I fill the entire cell with a color using fillRect 0,0,g.width, g.height.

This works as desired on the Mac build, but it seems that the CellBackgroundPaint event never gets fired in response to the invalidate (or refresh, even) call in the DragOver event.

What might I be doing wrong?

Oops. I left out a critical bit:

should have been:

It does for me on both windows and Mac… I have the row background turn red if you can’t drop there and green if you can.

Thank you, Karen.

It sounds like your implementation is very similar to mine. I’ve duplicated my problem on both Windows Vista and Windows 8. I can’t figure out what I’m doing wrong, especially since it works as it should on the Mac.

I know that the “invalidate” (or “refresh”) call is being made from within the “DragOver” event handler, but if i put a break point in the “CallBackgroundPaint” handler, it does not get hit so long as I am dragging.

Hmmmmm…

Some code might be useful. A sample project would be even better.

I’ve found the problem, though I don’t know why this is the case exactly. While my finding that in a Windows build, CellBackgroundPaint doesn’t fire during the drag in response to a call to invalidate or refresh, it turns out that it WILL fire in response to a call to invalidateCell for the cell in question (and for the previously highlighted cell, if any).

Thanks for your confirmation that you have it working, Karen; it made me dig further. Out of curiosity, do you use invalidate or invalidateCell in your code?

Thanks to all.
I tried to refresh / invalidate my whole listbox from the doubleClick event and noting happened. Using me.invalidateCell(-1,-1) works and repaints my whole listbox.

Great. I’m glad at least that the two hours of fooling around I did was of help to others too :slight_smile:

[quote=40815:@Peter Truskier]Thanks for your confirmation that you have it working, Karen; it made me dig further. Out of curiosity, do you use invalidate or invalidateCell in your code?

[/quote]
invalidateCell

Thanks. I guess it’s a subtle platform difference…

i am having this problem if i use invalidatecell with the color as a variable. if I type the color directly it is fine. any thoughts?