Add Items to Quick Access Toolbar
You can add your own custom items to the quick access toolbar using the mw.desktop.quickAccess
extension point.
Start by creating a JSON file named extensions.json
in a folder named
resources
. For each custom item that you want add to the quick access
toolbar, define an object within the items
array of the
mw.desktop.quickAccess
extension point. When adding multiple custom
items, separate each object with a comma.
For example, this extensions.json
file uses the
mw.desktop.quickAccess
extension point to add a push button to the
quick access toolbar.
{ "mw.desktop.quickAccess": { "items": [ { "name": "mytoolbox.openCustomFunction", "type": "PushButton", "action": { "text": "Open Custom Function", "description": "Open my custom function", "icon": "./icons/Open_16.png", "callback": "openMyFunction" } } ] } }
Create User-Defined MATLAB Function
To perform an action when a custom item in the quick access toolbar is clicked or
selected, create a function that performs the intended action. Then specify the function
name as the value of the callback
property. Place the function in a
folder on the MATLAB® path to make it available.
For example, create the function openMyFunction
, which is referenced
by the callback
property in the JSON file. MATLAB calls this function when you click the custom
openCustomFunction
button in the quick access toolbar. When called, the
function prints a message in the Command Window and opens myWorkingFile.m
in the Editor.
function openMyFunction disp("Opening 'myWorkingFile.m' in the Editor...") edit myWorkingFile.m end
Enable Your Customizations
To enable your customizations, add the folder containing the
resources
folder with the extensions.json
file to
the path. When the folder is added to the path, a new button appears in the quick access
toolbar.
When you click the button, the openMyFunction
function is called
.openMyFunction
opens the file myWorkingFile.m
in
the Editor and prints this text to the Command Window:
Opening 'myWorkingFile.m' in the Editor...