First, thanks for the interesting topic (+1).
Here's a simpler way of issuing multiple actions when pressing the Restore toolbar button without hard coding the original callback function which is undocumented, hidden in p-code, and liable to change in the future.
- Get the handle to the Restore button in the axes' toolbar.
- Capture and store the original callback function.
- Overwrite the buttons' callback function by defining a new function where you can execute the original callback function plus do anything else you want. This demo merely shows a uialert to confirm that the axes are restored.
Tested in r2020b and r2021a.
app.UIAxes = uiaxes(app.UIFig);
axTB = axtoolbar(app.UIAxes,'default');
isRestoreButton = strcmpi({axTB.Children.Icon},'restoreview');
restoreButtonHandle = axTB.Children(isRestoreButton);
originalRestoreFcn = restoreButtonHandle.ButtonPushedFcn;
restoreButtonHandle.ButtonPushedFcn = {@myRestoreButtonCallbackFcn, originalRestoreFcn};
function myRestoreButtonCallbackFcn(hobj, event, originalCallback)
originalCallback(hobj,event)
fig = ancestor(event.Axes,'figure');
uialert(fig,'Axes restored', 'RestoreButtonCallback', 'Icon', 'info');
Best Answer