[flexcoders] Stopping double-click of a button 'bubble' to the datagrid row
Hello, I've got an advancedDataGrid (AvDG) and the first column has an item renderer which has a button on it. The button has a click handler. There is also a itemDoubleClick handler on the AvDG. Users are double-clicking the button so this is firing the click of the button handler but the doubleClick event is also being fired on the AvDG row item. I'm guessing this is related to event bubbling or capturing? I'm trying to stop the AvDG.row doubleClick event being fired if the user double clicks on the button. Anyone got any ideas? I've tried to put a doubleClick on the button in hope that it would handle it and therefore stop the row event from being fired but ti didn't work. Now I think i need to capture the doubleClick cancel event in the button object and prevent it from bubbling from the button to the AvDG. Where do I set event.cancelable = true? Thanks, Nick
RE: [flexcoders] Stopping double-click of a button 'bubble' to the datagrid row
MouseEvents are not cancelable. You can kill them via stopImmediatePropagation. 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 Nick Middleweek Sent: Tuesday, September 01, 2009 9:56 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Stopping double-click of a button 'bubble' to the datagrid row Hello, I've got an advancedDataGrid (AvDG) and the first column has an item renderer which has a button on it. The button has a click handler. There is also a itemDoubleClick handler on the AvDG. Users are double-clicking the button so this is firing the click of the button handler but the doubleClick event is also being fired on the AvDG row item. I'm guessing this is related to event bubbling or capturing? I'm trying to stop the AvDG.row doubleClick event being fired if the user double clicks on the button. Anyone got any ideas? I've tried to put a doubleClick on the button in hope that it would handle it and therefore stop the row event from being fired but ti didn't work. Now I think i need to capture the doubleClick cancel event in the button object and prevent it from bubbling from the button to the AvDG. Where do I set event.cancelable = true? Thanks, Nick
Re: [flexcoders] Stopping double-click of a button 'bubble' to the datagrid row
Event.stopPropagation() or stopImmediatePropagation() (depending on whether you want events on the current node to be executed before the event stops or not: ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml; layout=horizontal xmlns:local=* mx:Script ![CDATA[ [Bindable] public var dp:Array = [ {foo: button 1}, {foo: button 2}, {foo: button 3}, {foo: button 4}, {foo: button 5}, {foo: button 6}, ]; private function dg_doubleClickHandler(event:Event):void { trace('dg double click'); } ]] /mx:Script mx:AdvancedDataGrid id=dg doubleClickEnabled=true doubleClick=dg_doubleClickHandler(event) dataProvider={dp} mx:columns mx:AdvancedDataGridColumn dataField=foo mx:itemRenderer mx:Component mx:Button doubleClickEnabled=true label={listData.label} doubleClick=trace(listData.label + ' double click'); event.stopImmediatePropagation(); / /mx:Component /mx:itemRenderer /mx:AdvancedDataGridColumn /mx:columns /mx:AdvancedDataGrid /mx:Application Beau On Tue, Sep 1, 2009 at 10:55 AM, Nick Middleweek n...@middleweek.co.ukwrote: Hello, I've got an advancedDataGrid (AvDG) and the first column has an item renderer which has a button on it. The button has a click handler. There is also a itemDoubleClick handler on the AvDG. Users are double-clicking the button so this is firing the click of the button handler but the doubleClick event is also being fired on the AvDG row item. I'm guessing this is related to event bubbling or capturing? I'm trying to stop the AvDG.row doubleClick event being fired if the user double clicks on the button. Anyone got any ideas? I've tried to put a doubleClick on the button in hope that it would handle it and therefore stop the row event from being fired but ti didn't work. Now I think i need to capture the doubleClick cancel event in the button object and prevent it from bubbling from the button to the AvDG. Where do I set event.cancelable = true? Thanks, Nick -- Beau D. Scott Software Engineer