Working With EVRIADDON
The evriaddon object allows for existing functions to "query" for additional functionality. A good example is a function that lists import methods. This function might construct a list of known import methods then "query" evriaddon for any additional import methods that a user may have added.
Examples
Adding an PLOTGUI Toolbar Button
In this example we'll add a button to the plotgui toolbar (the toolbar that appears on the "target" figure) that creates a static plot.
1) The function that uses evriaddon in this situation is plotgui_toolbar.m. Opening this function we can see that to add a button we need to add an entry to the list (n x 7 cell array of strings) of buttons with the following format:
icon | tag | callback | enable/disable | tooltip | separator on/off | push/toggle button |
---|
Create a function (in the PLS_Toolbox/utilities folder) named "myplotguibuttons.m". All the function will do is take the existing button list and add an entry for an additional button. Looking at where plotgui_toolbar.m calls evriaddon I know it passes two inputs, the button list (btn) and figure handle (targfig). We ignore targfig for now because we don't need any figure information. The code should then be simply:
function btn = myplotguibuttons(btn,targfig) %MYPLOTGUIBUTTONS Utility function to add toolbar buttons. btn = [btn { 'plot' 'makestaticplot' 'plotgui(''menuselection'',''ViewSpawn'')' 'enable' 'Create a static plot.' 'on' 'push' }];
I chose the "plot" icon, a unique tag name, a simple plotgui command, and appropriate values for the rest of the settings.
2) In the PLS_Toolbox/utilities/@evriaddon folder, open the addon_pls_toolbox.m file. Here, add a "entry point" for plotgui_toolbar and assign it the function handle of the function we created in step 1. It should look similar to:
... out.priority = 1; out.importmethods = @editds_importmethods; out.preprocess = @preprouser; out.plotgui_toolbar = @myplotguibuttons; ...
3) Test your new button:
load arch plogtgui(arch)