我有一個ItemRenderer,其中選定的狀態應該被禁用(我使用渲染器狀態,我沒有選定的狀態)。 問題是,即使我沒有「選擇」狀態,列表(spark)也會在點擊時重置項呈示器狀態。flex防止火花列表上的選擇狀態
我想完全防止這種行爲,但我不知道如何。 我的渲染器將autoDrawBackground設置爲false,但必須啓用它(雖然enabled = false可修復此問題) 此外,渲染器有幾個子項,包括其自己的列表。 在渲染器上設置mouseEnabled =「false」可修復渲染器本身,但不修復其子代,並且我需要一些兒童啓用鼠標。
編輯:
以下是我的項目渲染器的摘錄:
<?xml version="1.0" encoding="utf-8"?>
<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:s="library://ns.adobe.com/flex/spark"
width="100%" autoDrawBackground="false">
<s:states>
<s:State name="normal" />
<s:State name="suitable" />
<s:State name="mine" />
<s:State name="deleted" />
</s:states>
<s:Rect id="rect" top="0" right="0" bottom="0" left="0">
<s:fill>
<s:SolidColor id="background"
alpha=".8" alpha.deleted=".4"
color="0xff0000" color.suitable="0x00ff00" color.mine="0x0000ff" />
</s:fill>
</s:Rect>
<s:Label id="name" left="4" top="4" right="40" />
<s:List id="myList" left="4" top="40" right="4"
contentBackgroundAlpha="0" borderVisible="false" horizontalScrollPolicy="off">
<s:layout>
<s:VerticalLayout gap="3" paddingBottom="4" requestedMinRowCount="2" />
</s:layout>
</s:List>
</s:ItemRenderer>
第二個編輯:
我不得不用鼠標懸停狀態相同的問題,但似乎有一個解決方法:
override protected function set hovered(value:Boolean) : void
{
// do nothing (prevent current state from changing to "hovered" state)
}
你可以發佈你的渲染器的代碼 – 2013-10-17 10:01:16
可能的重複[如何防止在列表中選擇一個項目](http://stackoverflow.com/questions/12254718/how-to-prevent-an-item從列表中選擇) – splash
@splash,我看過這篇文章,但添加「更改」事件並沒有解決我的問題 – Ofir