MATLAB Answers

How to get state of the default axestoolbar buttons in UIAxes? And how to turn them on or off programmatically?

10 views (last 30 days)
Hi,
I have a plot with a callback function 'buttonDownFcn' that applies the area function to plot a tranparent square on top of the data. I don't want my callback function to run if any of the default state buttons are pressed.
How to get the state of the default buttons of the axestoolbar in UIAxes?
Another workaround is to create an extra button that, when enabled, enables the callback function. But unfortunately I still need set the state of the other default buttons to 0 if the have been pressed previously, otherwise they will interfear with my callback function.
I have just upgraded to R2020b where Mathworks have added more supported features to UIAxes when comparing to R2019b, but I know that there still are some limitations and not supported features in UIAxes, e.g. buttons and availabe callback functions...
So maybe it is not yet possible to "read" the button state values of the axestoolbar in UIAxes?
Any help is apriciated!
Regards Anders.

Accepted Answer

Mario Malic
Mario Malic on 13 Oct 2020
Edited: Mario Malic on 13 Oct 2020
Hi Anders,
  • Looks like there's a possibility of changing the button state on toolbar.
app.PulsePlotUIAxes.Toolbar.Children(2).Value = 'off'
% ^ Axes handle you're ^ There are 8 children in standard toolbar
% interacting with so you have to do this command for every single one of them
First child is a toolbardropdown and it doesn't have the Value property, so there's no need to change it.
  • You can try temporarily disabling interactions in your buttonDownFcn (but I am not sure if that's going to work since toolbar buttons are independent of interactivity). Here's an answer how to disable interactivity.
  • Maybe you could add a button to the toolbar that executes a callback, that way you are sure that none other button has been selected. toolbar button

  1 Comment

Anders Skovlund Hansen
Anders Skovlund Hansen on 13 Oct 2020
Hi Mario,
Thanks, that was just what I needed!
I couldn't find the correct properties of app.UIAxes.Toolbar.Children but off course that makes sense when the different children has different properties depending on wether its a ToolbarStateButton or a ToolbarPressButton! (.Value does not apply press button)
Thanks again!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!