I want to know if a plug-in of the General Plugin type can use Xib?How to load it，and how to show it by user NSMenuItem？
You connect the menu item to a method that then shows the window: https://snippets.aktagon.com/snippets/357-Showing-and-hiding-an-NSWindow-programatically
Sorry, I don’t know much about Object-C yet. Can you help me write an example? Thank you very much
What part do you nee help with?
The general plugin template has the code for to add the menu.
It even contains a method “showWindow”.
import objc from GlyphsApp import * from GlyphsApp.plugins import * class MYPlugin(GeneralPlugin): dialog = objc.IBOutlet() def settings(self): self.menuName = "My Plugin Name" # Load dialog from .nib (without .extension) self.loadNib('IBdialog', __file__) def start(self): newMenuItem = NSMenuItem(self.menuName, self.showWindow_) Glyphs.menu[EDIT_MENU].append(newMenuItem) def showWindow_(self, sender): self.dialog.makeKeyAndOrderFront_(self) def __file__(self): """Please leave this method unchanged""" return __file__
dialog outlet has to be connected to the window in the
Thanks, but when I used it,it caused a crash like this:AttributeError: ‘NSView’ object has no attribute ‘makeKeyAndOrderFront_’
I checked the information.makeKeyAndOrderFront_ was used in NSWindow，I can’t find the NSWindow Class in the xcode,
How should I solve it?
You need to build the full dialog as a window, now. Add a window to the .xib, add all the controls you need into it and connect it to the
I did as you said, but as soon as it opened the app, the window popped up. I think it popped up only when I clicked on the button on the menu.
The error message states that
self.dialog contains a NSView and not a NSWindow. If you did as I said, it should work. Can you send me the plugin code?
I’ve replaced Window and it’s displayed correctly. I mean, as soon as I open the software, the dialog that I maked pops up, not when I click on the name of the menu I customize on the menu.
There is a setting in the window in Xcode: “Visible At Launch”. That has to be disabled.
I just found it and tested it successfully. Thank you.