Search code examples
macos-carbonnsmenuitemnsmenucustom-viewgaps-in-visuals

How to remove NSMenuItem gap above custom view


I was looking for something discussed in following posts.

Gap above NSMenuItem custom view.

Reverse engineering an NSMenu for a Status Bar Item

I tried the carbon code provided by Pierre Bernard

initially, i was getting same error "EXC_BAD_ACCESS on the line InstallControlEventHandler" like other had. I play with the code lots and accidently found the solution.

I have just replaced the InstallControlEventHandler function call to HIViewInstallEventHandler and everything is working fine.

Hope this will help others. Let me know if anyone need further clarification.

Special thanks to Pierre Bernard to provide great code.

Thanks


Solution

  • Just replace the InstallControlEventHandler function call to HIViewInstallEventHandler and code will work fine.

    Thanks