list的问题

kingyoung1 2010-06-13 01:52:00
怎么让list在MOUSE_DOWN时就选中list中的cell,而不是click的时候。
...全文
34 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
清风水岸 2010-06-13
  • 打赏
  • 举报
回复
楼上正解
leecyz 2010-06-13
  • 打赏
  • 举报
回复

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">

<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300">
<mx:Script>
<![CDATA[
[Bindable]
private var dp:Array = [{name:"John Smith", foo:"bar"},
{name:"Ellen Smith", foo:"baz"},
{name:"James Smith", foo:"eggs"},
{name:"Jane Smith", foo:"spam"}]

public function init():void{

this.addEventListener(MouseEvent.MOUSE_DOWN,getItem);
}

private function editEnd(event:Event):void
{
trace(listImpl.selectedItem.foo+'----'+listImpl.selectedItem.name);
}

private function setEditor():void
{
listImpl.editedItemPosition = {columnIndex:0,rowIndex:2};
}

public function getItem(event:MouseEvent):void
{
trace("========被选中了===========");
}
]]>
</mx:Script>

<mx:Button click="setEditor()"/>

<mx:List y="30" width="200" selectedIndex="6" id="listImpl"
selectionColor="#CCCCFF" labelField="name"
dataProvider="{dp}" editable="true"
itemEditBegin="trace(listImpl.editedItemPosition.columnIndex)"
itemEditEnd="editEnd(event)" editorXOffset="5"
editorYOffset="2"/>

</mx:Canvas>

</mx:Application>
alpyh 2010-06-13
  • 打赏
  • 举报
回复
给list添加Mouse_Down事件
leecyz 2010-06-13
  • 打赏
  • 举报
回复
使用Mouse_DOWN事件监听器。初始化时就监听鼠标事件。

4,328

社区成员

发帖
与我相关
我的任务
社区描述
多媒体/设计 Flex
社区管理员
  • Flex
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧