【发布时间】:2016-01-25 18:49:00
【问题描述】:
我有一个<s:List />,其中包含一堆files。在右键单击时,我在鼠标的 (x, y) 位置打开一个菜单,让用户“打开文件位置”。我的斗争是打开文件位置并选择(不打开)文件,就像 Window 的资源管理器一样。我最接近的方法是打开父文件夹并使用file.openWithDefaultApplication();,它会打开文件所在的文件夹,但不会向用户显示实际文件。
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 文件搜索吗?当它为您提供文件名列表时,您可以右键单击一个并选择“打开文件位置”,这将打开一个新的资源管理器窗口并自动向下滚动到自动为您突出显示/选择的所述文件...
-
@Jordan.J.D,我不知道这是否可能。也许您可以执行一个 Windows CMD 终端命令(作为 NativeProcess?)以突出显示预期的文件。您必须四处搜索才能看到
-
@Sleeper,如果你还需要什么,请告诉我。
标签: file actionscript-3 air