Thanks, Alex. That does work, though the new item is still highlighted first, so I might be better of using "change", thus covering keyboard selection as well.
I saw a Gumbo example on flexexamples using a selectionChanging event, so it seems as though this use case will be supported in future. On Thu, May 14, 2009 at 11:53 PM, Alex Harui <[email protected]> wrote: > > > List/DataGrid don’t use click. They use mouseDown/mouseUp. You can try > blocking those events. > > > > Alex Harui > > Flex SDK Developer > > Adobe Systems Inc. <http://www.adobe.com/> > > Blog: http://blogs.adobe.com/aharui > > > > *From:* [email protected] [mailto:[email protected]] *On > Behalf Of *Richard Rodseth > *Sent:* Thursday, May 14, 2009 11:29 PM > *To:* [email protected] > *Subject:* [flexcoders] Preventing list selection > > > > > > > I need to disallow navigation away from unsaved changes based on the > user's response in an alert. > > I have some application-wide strategies in mind, and I have also seen how I > can prevent tab switching in a tab navigator by registering a capture-phase > click listener and calling stopImmediatePropagation and preventDefault. > > But the same strategy didn't work on a DataGrid, where the grid selection > is used as a form of navigation: > > <mx:DataGrid id="roleList" > creationComplete="onGridCreationComplete(event)" > > private function onGridCreationComplete(event:Event):void { > myGrid.addEventListener(MouseEvent.CLICK, onClickGrid, true, > 10); > > } > private function onClickGrid(event:Event):void { > // alert goes here > event.stopImmediatePropagation(); > event.preventDefault(); > } > > As a workaround I could handle the change event and restore the previous > selection but it would be better to conditionally suppress the selection. > > I've seen the post on Alex's blog, but am hoping for something > listener-based. Thanks. > > >

