我有一個<s:List />
,其中包含一堆files
。在右鍵點擊時,我在鼠標的(x,y)位置打開一個菜單,讓用戶「打開文件位置」。我的努力是打開文件位置並選擇(不打開)文件,就像Window的資源管理器一樣。最近我打開父文件夾並使用file.openWithDefaultApplication();
,它打開文件所在的文件夾而不顯示用戶實際文件。使用as3打開文件位置
MXML
<s:List
id="fileDownList"
height="100%"
width="100%"
dataProvider="{files}"
labelField="name"
allowMultipleSelection="false"
rightClick="rightMouseDown(event)"
itemRollOver="currentItem = event.itemRenderer.data"
/>
AS3
private function rightMouseDown(event:MouseEvent):void {
createMenu(currentItem, event.stageX, event.stageY);
}
private function createMenu(item:Object, xPos:int, yPos:int):void {
if (menu != null) {
menu.hide();
}
var menuItems:Array = [];
menuItems.push({label:"Open File Location"),
func: function run():void{
//runs on doMenuAction listener, need to open location here
}
});
if (menuItems.length > 0) {
menu = Menu.createMenu(tree, menuItems);
//noinspection JSValidateTypes
menu.addEventListener(MenuEvent.ITEM_CLICK, doMenuAction);
}
if (menu != null) {
menu.show(xPos, yPos);
}
}
例
不清楚你在問什麼。另外 - 基於瀏覽器?空氣? –
@Sleeper什麼部分不清楚,所以我可以澄清?這是一個AIR桌面應用程序。 –
@Sleeper,你有沒有使用Windows文件搜索?當它給你一個文件名的列表,你可以右鍵單擊一個,然後選擇「打開文件位置」,它會打開一個新的資源管理器窗口,並自動向下滾動到所選文件的位置,並自動突出顯示/選擇... –