AppDesigner: Getting a UIAxes' enableDefaultInteractivity to work with a UIFigure's WindowButtonDownFcn?
Show older comments
Dear all,
I would greatly appreciate any help with the following problem I am encountering. I will try to describe everything as clear as possible.
My Goal:
I am trying to create an app in AppDesigner where I can 'select' points in a figure. The selection will have to work similar to a 'brush', where all points are triggered in proximity of the mouse. The behaviour looks similar to the defualt brush function, but that function only allows dragging of a box. The data I use in my figures is more curved and complex, and would not suit the 'square' approach of the brush function very well.
I want the figure to work with the "enableDefaultInteractivity" behaviour of MATLAB UIAxes. This means that i can drag the figure by clicking and holding the mouse, and zoom with the mousewheel on the location the pointer is at that point. When clicking a button, I want to switch to a "brushing-mode", where i can click in the figure and start "painting" datapoints in my figure.
The Problem:
Whenever the WindowButtonDownFcn of the app itself is added, this will automatically disable the enableDefaultInteractivity of the figure. By default, I would right-click the "app.UIFigure" in the Component Browser, and select "Callbacks -> Window Callbacks -> add WindowButtonDownFcn callback", but this immediately disables the enableDefaultInteractivity and I cannot restore it.
As a workaround, I defined the desired WindowButtonDownFcn in the apps startupFcn as follows:
app.UIFigure.WindowButtonDownFcn = {@MouseDown, app};
This at least means I have expected behaviour up to the point of performing the desired tasks. However, when the datapoint selection is completed (through a WindowButtonMotionFcn and a WindowButtonUpFcn), the enableDefaultInteractivity is disabled, and I cannot restore it.
The Code:
I have appended a dumbed-down app that demonstrates the problem. It is a very simple app containing one single figure and one button. Upon running the code, a square is plotted. The figure can be dragged and zoomed as expected. When the button is pressed, the user can click (and hold down!) the mousebutton in the figure, and drag the displayed 'brush' over the datapoints, which will then light up.
When releasing the button, the points remain visible. However, now the figure cannot be dragged or zoomed anymore.
Any help is appreciated! Kind regards,
Mark
Accepted Answer
More Answers (0)
Categories
Find more on Interactive Control and Callbacks in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!