简体   繁体   English

是否可以从仪表板小部件中创建新的小部件实例?

[英]Is it possible to create new widget instances from within a Dashboard widget?

This is a followup to this question .这是这个问题的后续。
It seems to be impossible to to simply keep already configured dashboard widget instances.简单地保留已配置的仪表板小部件实例似乎是不可能的。 An alternative way would be to recreate previous instances.另一种方法是重新创建以前的实例。

Is it possible to create new Dashboard widget instances from within another widget?是否可以从另一个小部件中创建新的仪表板小部件实例? I couldn't find anything about this topic, yet.我还没有找到关于这个主题的任何信息。

It is possible, but I don't know how.这是可能的,但我不知道如何。 The Delivery Status widget allows you to open a new copy of itself.交付状态小部件允许您打开其自身的新副本。 You can see the + sign in the screenshot in the help image .您可以在帮助图像的屏幕截图中看到 + 号。

I would doubt it... I assume there's an implied security risk in that.我会怀疑它......我认为其中存在隐含的安全风险。

You'd probably be best served by looking through Apple's code.查看 Apple 的代码可能会为您提供最好的服务。 When you "update" a widget, do you change the identifier, or does it automatically wipe the preferences?当您“更新”小部件时,您是更改标识符,还是自动擦除首选项? (Pardon my ignorance- I'm away from my Mac, so I can't investigate myself) (请原谅我的无知 - 我远离我的 Mac,所以我无法调查自己)

Other than that, though, you'd probably want to look for "Dashboard Widget preferences wiped by update", either on 'flow or on the Apple forums.但是,除此之外,您可能想在“流程”或 Apple 论坛上查找“通过更新擦除的仪表板小部件首选项”。 The email lists are particularly helpful.电子邮件列表特别有用。

AFAIK it's not possible in any supported way (there's no mention of it in Apple's documentation, Dashboard doesn't have AppleScript dictionary). AFAIK 不可能以任何受支持的方式(Apple 的文档中没有提到它,仪表板没有 AppleScript 字典)。

However, since Widgets can have access to the filesystem and execute commands, it is possible to hack it: modify com.apple.dashboard.plist and restart Dashboard with killall Dock (obviously that's not elegant solution).但是,由于 Widget 可以访问文件系统并执行命令,因此可以对其进行破解:修改com.apple.dashboard.plist并使用killall Dock重新启动 Dashboard(显然这不是优雅的解决方案)。

This is not possible.这不可能。 I had also tried it before.我之前也试过。

I thought perhaps you could use widget.system to call the open command on the widget bundle and open a new copy, so I put together a simple widget to test it out.我想也许你可以使用widget.system来调用widget bundle 上的open命令并打开一个新副本,所以我组合了一个简单的widget来测试它。 No go.不行。

I wonder, though, if an Objective-C plugin would be any more capable or if this is a restriction baked into the Dashboard environment?不过,我想知道,Objective-C 插件是否会更有能力,或者这是否是 Dashboard 环境中的限制?

Well, this was possible with an earlier version of OS X. In a widget I made I used the following code to create a new instance:嗯,这在早期版本的 OS X 中是可能的。在我制作的小部件中,我使用以下代码创建了一个新实例:

widget.system('/bin/sh -c "open `pwd`"', null);

Now however, this code reinstalls the widget.但是,现在此代码会重新安装小部件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM