How can I mimic a ButtonDownFcn for a UIAxes in R2019a?

How can I mimic a ButtonDownFcn for a UIAxes in MATLAB R2019a, where this callback is not explicitly supported?

 Accepted Answer

Upgrading to a newer versions of MATLAB which supports UIAxes ButtonDownFcn is still the easiest workaround. Another workaround is adding the callback to the image itself rather than the axes.
If these workarounds do not work for your app, there is one more workaround. Regular axes are supported in App Designer as of R2018b, but they are not available in the graphical environment. You can, however, create them programmatically using the "axes" command, such as in the app's startup function. ButtonDownFcn is supported on regular axes in App Designer, and this behaves just like ButtonDownFcn on axes in GUIDE app. Please save a backup copy of your app first so that you can restore the old version if needed.
Then, you can replace all of the UIAxes in your app with panels if you have the axes in a grid layout or scrollable container. If the axes will not be in a grid layout or scrollable container, the panel will not be necessary. The panel will allow you to position a "placeholder" where the axes will go in the app. In addition, in R2019a the axes cannot be placed directly in a grid layout or scrollable container, but it can be placed within a panel that is in a grid layout or scrollable container.
Either with the startup function or some other callback, you can then call the "axes" command and set the panel as the parent- the axes will fill the panel, and the behavior will be very similar to UIAxes but it will support ButtonDownFcn.

More Answers (0)

Categories

Find more on Develop Apps Programmatically in Help Center and File Exchange

Products

Release

R2019a

Tags

No tags entered yet.

Community Treasure Hunt

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

Start Hunting!