Using macoslib and dockMenuDev together

I’ve been stuck on this for a couple of days. Admittedly, I’m not terribly familiar with Objective-C. I’ve got the macoslib project, which is working great, and then I found dockMenuDev to create a menu in the Dock icon. I need the functionality of both for my app, but I cannot get them to work together. I’ve tried multiple forms of merging and fiddling with the code, but I’m still getting a number of errors. Where I’m at now is I’ve added the DockMenu module to a project with macoslib installed, but did not bring in My NSMenu, as that seems to break macoslib in many ways.

The errors I’m struggling with are mainly:

[code]LINE: theMenu.addItem(new NSMenuItem(“New Window”, action, 0))
ERROR: “There is more than one item with this name and it’s not clear to which this refers.”

LINE: Type “Cocoa.NSMenu” has no member named “addItem”
ERROR: “theMenu.addItem(new NSMenuItem(“New Window”, action, 0))”

LINE: theMenu.getItem(1).setTitle("Render " + Str(pass))
ERROR: Type “Cocoa.NSMenu” has no member named “getItem”

LINE: return theMenu.getID
ERROR: “Type mismatch error. Expected Ptr, but got Int32”[/code]

Getting a few more errors, but they’re mostly variations of the above.

I apologize for my ineptitude here, but if anyone could shed any light on this, I would be truly grateful.

Thanks all.

I sparingly use this code based on macoslib 64b

nsd = New NSDockTile//nit it in the open event of the window

then, when necessary, I add a lebael:
nsd.BadgeLabel = “some string”.

I’ve got the badge label figured out, what I’m needing is options that appear under the Dock’s MENU when you long-click on the application’s Dock icon. macoslib doesn’t do this, which is why I need to use dockMenuDev. I’m just unable to get them to work nicely together.

Can you share a sample project where you’re trying to use both?

In theory they shouldn’t clash with each other directly, but because MacOSLib covers so much you may be having declare conflicts.

If your version of MacOS matches the one I have lying around here, you are using the wrong syntax. Could it be you mixed the method declarations with those of dockMenuDev?

The constructor for Cocoa.NSItem is

Public Sub Constructor(theTitle as string, aTag as integer)

Remove action from your code (if you need to set the action, use setAction, and then make


should be


and instead of setTitle, it’s simply

title = "Render " + Str(pass)

and finally

return theMenu.ID

P.S.: Or is it a case of name conflicts between both libraries?

I believe it is a conflict between both libraries. Here is a link to the project where I am trying to use both, and getting the errors. The only thing I’m trying to do here is create a StatusItem in the menubar and a Dock menu. I’ve combined macoslib and DockMenuDev as they are and you’ll see all the errors when trying to compile.


If you delete the “My NSMenu” module, the number of errors decreases quite a bit - I’m assuming because of multiple conflicts between the two libraries. I started there, but still wasn’t able to resolve the issues.

Thank you very much to all for your help.

It is indeed a naming conflict. Both libraries have an NSMenu and a NSMenuItem class, both with global scope. That does not work. I threw out the dockMenu library and made the changes I proposed above. All errors (except for Window.log which I commented out) disappeared.
Or kick out MacOSLib and your code should run.

Thank you very much Ulrich. Unfortunately I’m still not getting it to work. I get it to compile now, however no menu items appear in the Dock. I also had to comment out this line of code in the App’s Open event:

DockMenu.install(AddressOf getDockMenu)

It was giving me an error. So now the program compiles but I have no menu in the Dock, so something still isn’t working properly. That line of code is properly the cause, but I do not know how to properly invoke the DockMenu.