I would subclass List and restore anchorIndex and caretIndex when selectedItems 
is set.

From: [email protected] [mailto:[email protected]] On Behalf 
Of rviswanathan
Sent: Tuesday, December 23, 2008 12:53 PM
To: [email protected]
Subject: [flexcoders] Shift+Select - Issue with ListBase


Hi

I am reopening this topic. I am facing an issue with a list that allows
multi select. I am using Flex 2.0. I see that this is fixed in Flex 3.0, but
I am not sure how to go about fixing this problem in 2.0

I run the source code below.
1. On load of the application, I set the first item in the list as selected.
(selectedIndex = 0). At this point, I am able to use "Shift" key to multi
select.
2. I have a button, on click of this button, I change my selected items so
as to select the first 2 items (selectedIndices = 0 & 1). When this happens,
if I try to do a shift+select, it does not work (until I make another
selection either with a click or Ctrl+Click).

The anchor bookmark, anchor index, caret bookmark and caret index are not
getting set when I set selectedItems or selectedIndices. I see this fixed as
part of setSelectionIndicesLoop and setSelectionDataLoop in the Flex 3
ListBase.as.

Even if I attempt to subclass ListBase, I hit private members that I would
not be able to access. Is there any other workaround for me to fix this?

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
creationComplete="selectDefault(event);" >
<mx:Script>
<![CDATA[
private function selectDefault(e:Event) : void {
lst.selectedIndex = 0;
}

private function selectFirstTwo(e:Event) : void {
var arr:Array = [0,1];
lst.selectedIndices = arr;
}
]]>
</mx:Script>

<mx:List id="lst" allowMultipleSelection="true" width="100">
<mx:dataProvider>
<mx:String>AK</mx:String>
<mx:String>AL</mx:String>
<mx:String>AR</mx:String>
<mx:String>AB</mx:String>
<mx:String>AC</mx:String>
<mx:String>AD</mx:String>
</mx:dataProvider>
</mx:List>
<mx:Button label="Select First 2 Elements!"
click="selectFirstTwo(event)"/>
</mx:Application>

Thanks
Ram
--
View this message in context: 
http://www.nabble.com/Shift%2BSelect---Issue-with-ListBase-tp21151088p21151088.html
Sent from the FlexCoders mailing list archive at Nabble.com.

Reply via email to