[Flex] Really disable disabled items

On February 15, 2007, Flash / Flex - No Comments

I recently discoverd another bug in Flex 2.0.1 / ActionScript 3.0. You cannot trust the enabled property of some components. Especially listbased components like datagrids. When you set the enabled property of a datagrid to false, it still responses to doubleclicks and happily fires it’s events. Probably not what you want. The solution is fairly simple though:

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"  >
	<mx:DataGrid
		id="contentitemGrid"
		doubleClickEnabled="true"
		mouseChildren="{contentitemGrid.enabled}" />
</mx:Canvas>

By disabling it’s mouseChildren property, the clickevents of the datagrids children (the items) aren’t fired anymore, so the doubleclick is ignored.