<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Easy way to replicate Scripts menu bar?]]></title><description><![CDATA[<p dir="auto">I'd like to partition my Scripts folder, and have another application menu bar item alongside <code>Extensions</code>, <code>Scripts</code>, <code>Window</code> etc. with another menu corresponding to a directory on my HD. I've got the bare bones of a custom menu ready, but not sure if there's a stock function for linking the menu structure to a local directory.</p>
<p dir="auto">TIA!<br />
Ryan</p>
]]></description><link>https://forum.robofont.com/topic/612/easy-way-to-replicate-scripts-menu-bar</link><generator>RSS for Node</generator><lastBuildDate>Sat, 15 Aug 2026 04:27:27 GMT</lastBuildDate><atom:link href="https://forum.robofont.com/topic/612.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 09 Apr 2019 23:38:43 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Easy way to replicate Scripts menu bar? on Wed, 10 Apr 2019 03:55:26 GMT]]></title><description><![CDATA[<p dir="auto">I'd like to partition my Scripts folder, and have another application menu bar item alongside <code>Extensions</code>, <code>Scripts</code>, <code>Window</code> etc. with another menu corresponding to a directory on my HD. I've got the bare bones of a custom menu ready, but not sure if there's a stock function for linking the menu structure to a local directory.</p>
<p dir="auto">TIA!<br />
Ryan</p>
]]></description><link>https://forum.robofont.com/post/2207</link><guid isPermaLink="true">https://forum.robofont.com/post/2207</guid><dc:creator><![CDATA[ryan]]></dc:creator><pubDate>Wed, 10 Apr 2019 03:55:26 GMT</pubDate></item><item><title><![CDATA[Reply to Easy way to replicate Scripts menu bar? on Thu, 18 Apr 2019 13:41:38 GMT]]></title><description><![CDATA[<p dir="auto">hello <a class="plugin-mentions-user plugin-mentions-a" href="https://forum.robofont.com/uid/224">@ryan</a>,</p>
<p dir="auto">here’s a function to create a new menu item for a folder structure with .py files:</p>
<pre><code class="language-python">from AppKit import NSApp, NSMenu, NSMenuItem
from lib.UI.fileBrowser import RFPathItem

def addMenu(name, path):
    '''Creates a new menu item in RoboFont’s main application menu.'''

    # create a new menu
    menu = NSMenu.alloc().initWithTitle_(name)

    # create a path item that will build the menu and connect all the callbacks
    pathItem = RFPathItem(path, ['.py'], isRoot=True)
    pathItem.getMenu(title=name, parentMenu=menu)

    # get the main menu
    menubar = NSApp().mainMenu()

    # search if the menu item already exists
    newItem = menubar.itemWithTitle_(name)
    if not newItem:
        # if not, create one and append it before `Help`
        newItem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(name, '', '')
        menubar.insertItem_atIndex_(newItem, menubar.numberOfItems()-1)

    # set the menu as submenu
    newItem.setSubmenu_(menu)
    
addMenu('My Menu', '/path/to/scripts/folder')
</code></pre>
<p dir="auto">you can <a href="http://robofont.com/documentation/how-tos/setting-up-a-startup-script/" rel="nofollow">set it as a start-up script</a>, so the menu will always be there when you open RoboFont.</p>
<p dir="auto">(will be added to the docs soon… thanks!)</p>
]]></description><link>https://forum.robofont.com/post/2208</link><guid isPermaLink="true">https://forum.robofont.com/post/2208</guid><dc:creator><![CDATA[gferreira]]></dc:creator><pubDate>Thu, 18 Apr 2019 13:41:38 GMT</pubDate></item><item><title><![CDATA[Reply to Easy way to replicate Scripts menu bar? on Wed, 10 Apr 2019 11:55:54 GMT]]></title><description><![CDATA[<p dir="auto">Thanks, <a class="plugin-mentions-user plugin-mentions-a" href="https://forum.robofont.com/uid/22">@gferreira</a>! This is exactly what I was looking for. Do you know of any resources that explain how to work with AppKit? Apple’s documentation feels less accessible/thorough to me, but I could be missing something.</p>
<p dir="auto">Thanks again,<br />
Ryan</p>
]]></description><link>https://forum.robofont.com/post/2209</link><guid isPermaLink="true">https://forum.robofont.com/post/2209</guid><dc:creator><![CDATA[ryan]]></dc:creator><pubDate>Wed, 10 Apr 2019 11:55:54 GMT</pubDate></item><item><title><![CDATA[Reply to Easy way to replicate Scripts menu bar? on Wed, 10 Apr 2019 13:48:46 GMT]]></title><description><![CDATA[<ul>
<li>for the AppKit Apple docs opt for the objc version and replace <code>:</code> by <code>_</code> for the python version.</li>
<li>use <code>print(dir(nsObject))</code> to find all the methods and attributes</li>
</ul>
]]></description><link>https://forum.robofont.com/post/2210</link><guid isPermaLink="true">https://forum.robofont.com/post/2210</guid><dc:creator><![CDATA[frederik]]></dc:creator><pubDate>Wed, 10 Apr 2019 13:48:46 GMT</pubDate></item><item><title><![CDATA[Reply to Easy way to replicate Scripts menu bar? on Wed, 10 Apr 2019 16:50:55 GMT]]></title><description><![CDATA[<p dir="auto">the preferred way is to use <code>mojo.UI.MenuBuilder</code></p>
<pre><code class="language-python">from mojo.UI import MenuBuilder

def callback(sender):
    pass

builder = MenuBuilder([("test", callback), ("test 2", callback)])

menu = builder.getMenu()
print(menu)

name = "My Menu"

# get the menu bar
menubar = NSApp().mainMenu()

newItem = menubar.itemWithTitle_(name)
if not newItem:
    # if not, create one and append it before `Help`
    newItem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(name, '', '')
    menubar.insertItem_atIndex_(newItem, menubar.numberOfItems()-1)

# set the menu as submenu
newItem.setSubmenu_(menu)
</code></pre>
]]></description><link>https://forum.robofont.com/post/2211</link><guid isPermaLink="true">https://forum.robofont.com/post/2211</guid><dc:creator><![CDATA[frederik]]></dc:creator><pubDate>Wed, 10 Apr 2019 16:50:55 GMT</pubDate></item><item><title><![CDATA[Reply to Easy way to replicate Scripts menu bar? on Fri, 22 Jan 2021 18:50:44 GMT]]></title><description><![CDATA[<p dir="auto">Thanks <a class="plugin-mentions-user plugin-mentions-a" href="https://forum.robofont.com/uid/1">@frederik</a></p>
<p dir="auto">When I hit the native <code>Update Menu</code>, it doesn't update my custom menu item (if I added a new script, etc.)<br />
<img src="/assets/uploads/files/1611340942027-b1903a44-2506-4564-b3ff-5572998c762f-image.png" alt="b1903a44-2506-4564-b3ff-5572998c762f-image.png" class="img-responsive img-markdown" /></p>
<p dir="auto">Is there a way to update the custom menu without having to restart RF?<br />
The following little script seems to <strong>not</strong> work:</p>
<pre><code>import AppKit
menu = AppKit.NSApp().mainMenu()
menu.update()
</code></pre>
<p dir="auto">P.S. I did end up using <a class="plugin-mentions-user plugin-mentions-a" href="https://forum.robofont.com/uid/22">@gferreira</a> ’s menu-building script because it was already replicating a folder's pathing. Is there a way to mirror a folder with MenuBuilder?</p>
]]></description><link>https://forum.robofont.com/post/3568</link><guid isPermaLink="true">https://forum.robofont.com/post/3568</guid><dc:creator><![CDATA[ryan]]></dc:creator><pubDate>Fri, 22 Jan 2021 18:50:44 GMT</pubDate></item><item><title><![CDATA[Reply to Easy way to replicate Scripts menu bar? on Sat, 23 Jan 2021 11:09:59 GMT]]></title><description><![CDATA[<p dir="auto">yeah, "Update Menu" only updates from the script folder as set in the preferences.</p>
<p dir="auto">In Gustavo's example you'll need to add menu item with a callback to a script that is populating that menu. Hope that makes sense :)</p>
]]></description><link>https://forum.robofont.com/post/3569</link><guid isPermaLink="true">https://forum.robofont.com/post/3569</guid><dc:creator><![CDATA[frederik]]></dc:creator><pubDate>Sat, 23 Jan 2021 11:09:59 GMT</pubDate></item><item><title><![CDATA[Reply to Easy way to replicate Scripts menu bar? on Sat, 23 Jan 2021 21:08:06 GMT]]></title><description><![CDATA[<p dir="auto">Ah! Ok I rewrote Gustavo’s script to rebuild the menu each time it's run. So I can just rerun the script when I want it to update.</p>
<pre><code># menuTitle: _ Add / Update Custom Scripts Menu

from AppKit import NSApp, NSMenu, NSMenuItem
from lib.UI.fileBrowser import RFPathItem

def addMenu(name, path):
	'''Creates a new menu item in RoboFont’s main application menu.'''

	# create a new menu
	menu = NSMenu.alloc().initWithTitle_(name)

	# create a path item that will build the menu and connect all the callbacks
	pathItem = RFPathItem(path, ['.py'], isRoot=True)
	pathItem.getMenu(title=name, parentMenu=menu)

	# get the main menu
	menubar = NSApp().mainMenu()

	# search if the menu item already exists
	newItem = menubar.itemWithTitle_(name)
	if newItem:
	    menubar.removeItem_(newItem)
	
	newItem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(name, '', '')
	menubar.insertItem_atIndex_(newItem, menubar.numberOfItems()-3)

	# set the menu as submenu
	newItem.setSubmenu_(menu)
	
addMenu('menu name', '/path/to/folder/')
</code></pre>
<p dir="auto">Key lines:</p>
<pre><code>if newItem:
  menubar.removeItem_(newItem)
</code></pre>
]]></description><link>https://forum.robofont.com/post/3570</link><guid isPermaLink="true">https://forum.robofont.com/post/3570</guid><dc:creator><![CDATA[ryan]]></dc:creator><pubDate>Sat, 23 Jan 2021 21:08:06 GMT</pubDate></item></channel></rss>