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: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf 
Of Richard Rodseth
Sent: Thursday, May 14, 2009 11:29 PM
To: flexcoders@yahoogroups.com
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.

Reply via email to