Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » ArrayCtrl, HeaderCtrl & GridCtrl » [Bug]ArrayCtrl,MultiSelect.In WhenSel callback, selection status of last selected row is incorrect
[Bug]ArrayCtrl,MultiSelect.In WhenSel callback, selection status of last selected row is incorrect [message #51750] Mon, 13 May 2019 15:53 Go to next message
Maginor is currently offline  Maginor
Messages: 44
Registered: May 2019
Member
Hi, I have an ArrayCtrl A with MultiSelect enabled.
I use the WhenSel callback to get notified when the selection status changes.

Inside my callback function I do

int RowCount = A.GetCount();
	
for(int Row = 0; Row < RowCount; ++Row)
{
    if(A.IsSelected(Row)) 
    {
        //Do something
    }
}


This works fine if there is only one row selected, but if there are multiple, IsSelected() returns false for the latest row that was selected.

I could also check if the row is the cursor (which works), but that will not give the desired behaviour when the cursor is on a deselected row (which it for instance is if you ctrl-click to deselect something).

Alternatively, is there a better way to iterate over the selected rows than I do here?

Re: [Bug]ArrayCtrl,MultiSelect.In WhenSel callback, selection status of last selected row is incorrect [message #51785 is a reply to message #51750] Mon, 27 May 2019 15:48 Go to previous messageGo to next message
Maginor is currently offline  Maginor
Messages: 44
Registered: May 2019
Member
I have tried to debug it some more..

There seems to be two bugs:
- if you ctrl-click a row, the row is not marked as selected before the WhenSel callback is called.
- if you ctrl-click to deselect a row or to select a row when there is no previous selection, the WhenSel callback is not called at all.

I did find a workaround, which is to use WhenAction instead of WhenSel. WhenAction is called once when the cursor moves and then once again after the selection is updated. The only problem is that since it is called twice it does all the heavy lifting of updating my plot twice every time (it seems fine with my current dataset, but could potentially be problematic with a larger one).
Re: [Bug]ArrayCtrl,MultiSelect.In WhenSel callback, selection status of last selected row is incorrect [message #51811 is a reply to message #51785] Fri, 07 June 2019 10:39 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Hopefully fixed.

(testing code in upptst/ArrayCtrlSel)
Previous Topic: ArrayCtrl::Paint is called three times
Next Topic: Restore original row order
Goto Forum:
  


Current Time: Fri Mar 29 12:04:58 CET 2024

Total time taken to generate the page: 0.01658 seconds