![]() |
|
||||||||||
|
|||||
|
Регистрация: Oct 2006
Сообщений: 44
|
Добрый вечер.
Попытался осуществить пример из мануала Flex 2 Developer's Guide > Customizing the User Interface > Working with Item Editors > Examples using item editors with the list controls а конкретно: Example: Using a custom item editor with a Tree control Я его немного переделал. Хочу чтоб пункты меню можно было редактировать налету: submenu.mxml <?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="600" height="600" xmlns="*">
<mx:Script>
<![CDATA[
import mx.events.ListEvent;
[Bindable]
public var contacts1:Object = {label: "top", children: [
{label: "Acme", children: [
{label: "Sales"},
{label: "Support"}
]},
{label: "Ace", children: [
{label: "Sales"},
{label: "Support"},
]},
{label: "Platinum"}
]};
// Initialize the Tree control.
private function initCatalog(cat:Object):void {
myTree.dataProvider = cat;
}
private function disableEditing(event:ListEvent):void {
if(event.rowIndex==0) {
event.preventDefault();
}
}
public function processData(event:ListEvent):void {
event.preventDefault();
myTree.editedItemRenderer.data.label = TreeEditor(event.currentTarget.itemEditorInstance).lab.text;
myTree.destroyItemEditor();
myTree.dataProvider.notifyItemUpdate(myTree.editedItemRenderer);
}
]]>
</mx:Script>
<mx:Tree id="myTree" width="400" height="400" editable="true" itemEditor="TreeEditor"
editorHeightOffset="75" editorWidthOffset="-100" editorXOffset="40" editorYOffset="30"
creationComplete="initCatalog(contacts1);"
itemEditBeginning="disableEditing(event);"
itemEditEnd="processData(event);"
/>
</mx:Application>
<?xml version="1.0"?>
<!-- TreeEditor.mxml -->
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" height="400" width="200">
<mx:Script>
<![CDATA[
// Define variables for the new data.
public var newLab:String;
]]>
</mx:Script>
<!-- Display item label.-->
<mx:HBox>
<mx:Text text="Label:"/>
<mx:TextInput id="lab" width="150" text="{data.label}" change="newLab=lab.text;" />
</mx:HBox>
</mx:VBox>
Последний раз редактировалось asuri; 26.10.2006 в 20:18. |
![]() |
![]() |
Часовой пояс GMT +4, время: 01:53. |
|
|
« Предыдущая тема | Следующая тема » |
|
|