题记:
第一次接触MAC的开发.....
Dock也是第一次听说,但弄明白后,这个东西就类似windows的任务栏。
这个Dock可以挂载一个叫NSDockTilePlugIn的
bundle,开发这个类似很多OSGI模型开发bundle一样,继承NSDockTilePlugIn,然后你实现相应的methods,完之后build出来放到指定的目录下,然后在某个特定的“动作”的时候会自动调用这些methods。
写道
The Dock tile plug-in must be placed inside the Contents/PlugIns directory of your application’s package. The plug-in is associated with the application by adding a NSDockTilePlugIn key to the application’s information property list. The value associated with this key is the name of the plug-in’s bundle, which must end with a .docktileplugin extension.
The principal class of the plug-in must implement the NSDockTilePlugIn protocol. The setDockTile: method is the only required method in this protocol. When the plug-in is loaded, an object of the principal class is instantiated, and its setDockTile: method is called. The call to this method provides an NSDockTile object to your plug-in. Your plug-in should retain the Dock tile object and perform any other initialization required by your plug-in. For example, if your plug-in receives information from a background-only application, it can register for a notification event sent by that other application.
Your Dock tile plug-in continues to run as long as your application’s tile is in the Dock, even if your application is actually running. Apple recommends that you update your Dock tile in either the application or the plug-in, but not both at the same time. Your application can continue to update the Dock tile inside your plug-in by having the plug-in receive notifications from your application. If both the application and the plug-in update the dock tile, the application takes precedence.
When your application is removed from the Dock, the setDockTile: method is called with a nil parameter. Your setDockTile: method should release the Dock tile object, clean up any resources your Dock Tile plug-in allocated, and exit.
这段主要内容是:
1,build后的bundle必须放到你app下的Contents/PlugIns下,且必须在property list文件中申明,其中内容为.docktileplugin结尾的插件名。
2,插件必须扩展NSDockTilePlugI,当插件加载的时候, setDockTile方法就会被执行,并且返回一个NSDockTile,你可以在这里做些其他初始化工作。
3,你的插件和主程序可以同时updateDock title,但主程序的优先级更高。
4,当你的application 从dock去除的时候,会把NSDockTile指向nil,在Object-C中指向nil的对象是自动释放内存并把指针指向NULL。
Dock Plugin 主要做几个工作:
1,其中更改dock上application的图标。
写道
Dock tile icons can be customized using an NSView object. This is useful if your application needs to dynamically generate Dock tile icons at run time. To provide a custom view, you instantiate a new view object, retrieve the dock tile object from the application or window object, and set your view as its contentView.
myView = [[[MyViewClass alloc] init] autorelease];
[[NSApp dockTile] setContentView: myView];
When the Dock icon needs to be updated, you instruct the Dock to update the icon by calling the dock tile object’s display method.
[[NSApp dockTile] display];
2,更改badge:
写道
The dock tile object can overlay a short text message on top of the Dock icon. To change the badge label, you call the Dock tile’s setBadgeLabel: method.
[[myWindow dockTile] setBadgeLabel:@"42"];
3,定义自己的menu:
写道
Your class can optionally provide a dockMenu method to provide additional custom menu items. This method works similarly to the applicationDockMenu: method provided by the application delegate. Mac OS X calls your plug-in’s dockMenu method when the user requests the menu for your Dock tile.
问题1:
Apple的官方文档说.docktileplugin要放到Contents/PlugIns目录下,可实现起来未必,我实践的时候放到了Resources目录下。
问题2:
设定Info.plist的时候注意key放到大概第一个<dict>下,类似:<dick><key>xxx</key><string>yyy</string></dick>
Good Luck:)
详情:http://developer.apple.com/library/mac/#documentation/Carbon/Conceptual/customizing_docktile/CreatingaDockTilePlug-in/CreatingaDockTilePlug-in.html#//apple_ref/doc/uid/TP30000986-CH4-SW1
分享到:
相关推荐
自己看的东西,没什么意义,关于qt 插件的资料,主要是自己看看
mac hadoop-eclipse-plugin-2.7.7
Apache Tomcat Maven Plugin - About Apache Tomcat Maven Plugin
WP about author plugin
AlwaysOnAmoledPlugin Always On AMOLED plugin
Citrix Online Plugin Web 安装程序
环境配置是:hadoop 2.4.0+ eclipse 4.3.2+mac os+10.9.4 eclipse插件
maven plugin maven plugin scm 项目管理 构建工具 antmaven plugin maven plugin scm 项目管理 构建工具 ant
unity3d资源,超酷的粒子特效,支持Windows、Mac和Linux
mybatis_plugin2.9.2
赠送jar包:spring-plugin-core-2.0.0.RELEASE.jar; 赠送原API文档:spring-plugin-core-2.0.0.RELEASE-javadoc.jar; 赠送源代码:spring-plugin-core-2.0.0.RELEASE-sources.jar; 赠送Maven依赖信息文件:spring...
mybatis_plugin 2.92 完美破解版 ,完美支持 Intellij IDEA 2017.1.4 替换 /Users/MacPro/Library/Application Support/IntelliJIdea2017.1/mybatis_plus/lib下的mybatis_plus.jar
derby_plugin derby_ui_plugin derby Eclipse插件
eclipse vi plugin 1.16 Here the ChangeLog: - 0000403: [editor_integration] would be nice to be able to use ctrl-v to paste clipboard when on search - 0000134: [eclipse_integration] editing a command ...
Pydroid repository plugin.xapk Pydroid repository plugin.xapkPydroid repository plugin.xapk
Jenkins Email Extension Plugin
Eclipse集成zk插件zk_plugin
- 此开发手册,分为4章12节循序渐进的通过实践案例开发的方式,串联 IDEA Plugin 开发的各项常用技术点,为读者讲解如何开发一个 IDEA 插件。 - 基本开发类知识点包括:`gradle 工程创建`、`插件发布`、`Swing UI`...
groovy eclipse plugin2groovy eclipse plugin2groovy eclipse plugin2groovy eclipse plugin2groovy eclipse plugin2groovy eclipse plugin2groovy eclipse plugin2
把ComparePlugin.dll文件放进ComparePlugin文件夹中,再把ComparePlugin文件夹放进npp安装目录下的plugins文件夹中,重启npp即可