<?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[Programmatically change menu shortcuts]]></title><description><![CDATA[<p dir="auto">Although there is a way to change shortcuts using a script, they don't update immediately. For example, the following code changes a glyph view shortcut instantly and I don't need to restart RF:</p>
<pre><code>from mojo.UI import exportPreferences, importPreferences

pref = exportPreferences()
pref['glyphViewQuickPreviewKey'] = ' '
importPreferences(pref)
</code></pre>
<p dir="auto">But although the below code also works (it's just an example), it only takes effect after restarting the app. Is there any way to make the changes to <code>menuShortCuts</code> instantly reflected in the UI?</p>
<pre><code>from mojo.UI import exportPreferences, importPreferences

pref = exportPreferences()
keys = {"File &gt; Save": [1048576, 'B']}
pref['menuShortCuts'] = keys
importPreferences(pref)
</code></pre>
]]></description><link>https://forum.robofont.com/topic/619/programmatically-change-menu-shortcuts</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Jul 2026 12:36:33 GMT</lastBuildDate><atom:link href="https://forum.robofont.com/topic/619.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 13 Apr 2019 21:07:09 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Programmatically change menu shortcuts on Mon, 15 Apr 2019 12:16:07 GMT]]></title><description><![CDATA[<p dir="auto">Although there is a way to change shortcuts using a script, they don't update immediately. For example, the following code changes a glyph view shortcut instantly and I don't need to restart RF:</p>
<pre><code>from mojo.UI import exportPreferences, importPreferences

pref = exportPreferences()
pref['glyphViewQuickPreviewKey'] = ' '
importPreferences(pref)
</code></pre>
<p dir="auto">But although the below code also works (it's just an example), it only takes effect after restarting the app. Is there any way to make the changes to <code>menuShortCuts</code> instantly reflected in the UI?</p>
<pre><code>from mojo.UI import exportPreferences, importPreferences

pref = exportPreferences()
keys = {"File &gt; Save": [1048576, 'B']}
pref['menuShortCuts'] = keys
importPreferences(pref)
</code></pre>
]]></description><link>https://forum.robofont.com/post/2244</link><guid isPermaLink="true">https://forum.robofont.com/post/2244</guid><dc:creator><![CDATA[bahman]]></dc:creator><pubDate>Mon, 15 Apr 2019 12:16:07 GMT</pubDate></item><item><title><![CDATA[Reply to Programmatically change menu shortcuts on Mon, 15 Apr 2019 13:20:33 GMT]]></title><description><![CDATA[<p dir="auto">hello <a class="plugin-mentions-user plugin-mentions-a" href="https://forum.robofont.com/uid/80">@bahman</a>,</p>
<p dir="auto"><s>I haven’t yet found out how to make the main menu update.</s> just a comment about the preferences API for now:</p>
<p dir="auto">you can read/write a single preference setting using <code>getDefault</code> and <code>setDefault</code>, and send a notification with <code>preferencesChanged</code>:</p>
<pre><code class="language-python">from mojo.UI import setDefault, getDefault, preferencesChanged

print('old settings:')
print(getDefault("glyphViewGridx"), getDefault("glyphViewGridy"))

gridsize = 70
setDefault("glyphViewGridx", gridsize)
setDefault("glyphViewGridy", gridsize)
preferencesChanged()

print('new settings:')
print(getDefault("glyphViewGridx"), getDefault("glyphViewGridy"))
</code></pre>
]]></description><link>https://forum.robofont.com/post/2247</link><guid isPermaLink="true">https://forum.robofont.com/post/2247</guid><dc:creator><![CDATA[gferreira]]></dc:creator><pubDate>Mon, 15 Apr 2019 13:20:33 GMT</pubDate></item><item><title><![CDATA[Reply to Programmatically change menu shortcuts on Mon, 15 Apr 2019 12:50:22 GMT]]></title><description><![CDATA[<p dir="auto">mojo.UI includes some additional functions for dealing with shortcut keys. (these are currently not listed in the docs, looking into it)</p>
<p dir="auto">use this API to modify the <code>menuShortCuts</code> preference AND update the application menu.</p>
<pre><code class="language-python">from mojo.UI import getMenuShortCuts, setMenuShortCuts

# get menu shortcuts
print(getMenuShortCuts().keys())
print()

# set menu shortcuts
shortcuts = {
    ('File', 'Save') : (1048576, 'b'),
    ('RoboFont', 'Check for Updates') : (1048576, "u"),
    ('RoboFont', 'License') : (1048576, "l"),
}
setMenuShortCuts(shortcuts)
print(getMenuShortCuts().keys())
</code></pre>
]]></description><link>https://forum.robofont.com/post/2248</link><guid isPermaLink="true">https://forum.robofont.com/post/2248</guid><dc:creator><![CDATA[gferreira]]></dc:creator><pubDate>Mon, 15 Apr 2019 12:50:22 GMT</pubDate></item><item><title><![CDATA[Reply to Programmatically change menu shortcuts on Mon, 15 Apr 2019 13:02:00 GMT]]></title><description><![CDATA[<p dir="auto">Gustavo that's very nice! Yes, I also think they should be included in the Docs. Thank you again!</p>
]]></description><link>https://forum.robofont.com/post/2249</link><guid isPermaLink="true">https://forum.robofont.com/post/2249</guid><dc:creator><![CDATA[bahman]]></dc:creator><pubDate>Mon, 15 Apr 2019 13:02:00 GMT</pubDate></item><item><title><![CDATA[Reply to Programmatically change menu shortcuts on Mon, 15 Apr 2019 13:03:52 GMT]]></title><description><![CDATA[<p dir="auto">ps. there’a also <code>removeMenuShortCut</code>, for ex:</p>
<pre><code class="language-python">removeMenuShortCut(('RoboFont &gt; Check for Updates'))
</code></pre>
<p dir="auto">…but it is not removing the shortcut from the menu. (I’ve filed a bug report)</p>
<p dir="auto">in the meantime, you can clear a shortcut by setting it to an empty string.</p>
]]></description><link>https://forum.robofont.com/post/2250</link><guid isPermaLink="true">https://forum.robofont.com/post/2250</guid><dc:creator><![CDATA[gferreira]]></dc:creator><pubDate>Mon, 15 Apr 2019 13:03:52 GMT</pubDate></item><item><title><![CDATA[Reply to Programmatically change menu shortcuts on Mon, 15 Apr 2019 13:09:37 GMT]]></title><description><![CDATA[<p dir="auto">Alright, I will consider this for my extension until it gets fixed. These are awaited features for me and very much appreciated.</p>
]]></description><link>https://forum.robofont.com/post/2251</link><guid isPermaLink="true">https://forum.robofont.com/post/2251</guid><dc:creator><![CDATA[bahman]]></dc:creator><pubDate>Mon, 15 Apr 2019 13:09:37 GMT</pubDate></item></channel></rss>