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

孤街浪徒 提交于 2019-12-12 10:59:03

问题


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.


回答1:


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.




回答2:


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. 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)

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. The email lists are particularly helpful.




回答3:


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).

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).




回答4:


Its not possible I had try it before also let me know if you get any solutions




回答5:


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. 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?




回答6:


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:

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

Now however, this code reinstalls the widget.



来源:https://stackoverflow.com/questions/1027240/is-it-possible-to-create-new-widget-instances-from-within-a-dashboard-widget

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!