![]() Available implementations of NSMenuExtra A nice tutorial is available at Cocoa Dev Central. Where are several implementations available with source code. Application Menu Switcher by Frank Vercruesse.They are very valuable examples, but personaly I've found that they are a bit too complex for the beginner. Another drawback, they are all distributed under GNU License, making it impossible for shareware/commercial developer to use their source code. You will definitly want to look at their source code at a later time to learn more about the NSMenuExtra functionality. The NSMenuExtra class resides in the SustemUIPlugin private framework. Objective-C keeps plenty of information about class names, inheritance, methods, e.t.c., so it is possible to get this information from the compiled binary. To obtain this framework API, we would use very useful class-dump utility by Steve Nygard. The class-dump is a command-line utility, so we will run it in terminal. If you put the "class-dump" binary inside the /Applications folder, then the command line would be /Applications/class-dump -e /System/Library/PrivateFrameworks/amework/Versions/A/SystemUIPlugin > SystemUIPlugin.h. Run this command, and check inside your home folder. You would find the "SystemUIPlugin.h" file in it. We need to do some editing before it will be compilable. Open it in Project Builder and look at its nice content. They should be: - initWithFrame:(NSRect)fp12 menuExtra:fp28 Replace the "expanded" struct _NSRect types in the initWithFrame and drawRect methods of NSMenuExtraView class.Remove the "?" sign in the struct declarations in the NSMenuExtra and NSDockExtra interfaces.First, add the #import just under the comments. Now we have the API to the NSMenuExtra (and the whole SystemUIPlugin) private framework.Ĭreate a new ProjectBuilder project using the Cocoa Bundle template. In ist entries/Cocoa Specific, set the Principal class to "SampleMenuExtra".In ist entries/Basic Information, set Identifier to something like "com.M圜ompany.SampleMenu".In Settings/Expert View, change the "WRAPPER_EXTENSION" from "bundle" to "menu".We need to tune some parameters, so select the "Targets" tab and click the "Sample" target. Add the "amework" either by drag-n-dropping it from Finder or via "Project/Add FrameWorks." menu. Then remove the "main.c" file from the project. Now copy the "SystemUIPlugin.h" file from your home folder to the project folder and add it to Classes group.Ĭreate the new class from the "Objective-C class" template.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |