Azzera filtri
Azzera filtri

Unexpected UIAxes Interaction behaviour

4 visualizzazioni (ultimi 30 giorni)
Mark Kamps
Mark Kamps il 1 Set 2023
Commentato: Raj il 20 Set 2023
Hello all,
I have an annoying little problem in Matlab that I fail to understand and don't know how to solve. Whenever I am making an app in AppDesigner, and I want to switch or change the built-in axes interactions, the app only becomes responsive if moving my mouse away from the UIAxis, onto a different item, and then moving back.
Attached is a small demonstrator app that shows the behaviour. This app plots a random 3D line with its default [rotate zoom]-interactions. When I press the Control-key it will switch this default interaction to [pan zoom]-interactions. Again pressing control will switch back (effectively toggling the behaviour).
However, upon pressing control (without moving the mouse) it will disable any interaction. Clicking and dragging the mouse will not do anything. Only when the mouse is moved off the UIAxes, onto some other part of the app (for example, a panel), and then back again, the interactions will function (and indeed be switched).
This is the main snippet of code that should hopefully make it clear:
% properties (Access = public)
Store % Container used for storing in the app
% Code that executes after component creation
function startupFcn(app)
% Set default parameter
app.Store.InteractionType = true;
% Create data to display
app.Store.Data = rand([10 3]);
% Plot data in UIAxes
app.Store.Plot = plot3(app.UIAxes, app.Store.Data(:,1), app.Store.Data(:,2), app.Store.Data(:,3), ...
LineWidth=2, Marker="o", MarkerEdgeColor=[1.0 0.6 0.6], MarkerFaceColor=[1.0 0.0 0.0]);
end
% Key press function: UIFigure
function UIFigureKeyPress(app, event)
% React to only the Control key
if strcmpi(event.Key, 'control')
% Change behaviour based on wether or not this has been clicked before, essentially "toggling"
% the behaviour
if app.Store.InteractionType
% Change the default behaviour to pan and zoom, and change value
app.UIAxes.Interactions = [panInteraction zoomInteraction];
app.Store.InteractionType = false;
else
% Change the default behaviour to pan and zoom, and change value
app.UIAxes.Interactions = [rotateInteraction zoomInteraction];
app.Store.InteractionType = true;
end
end
end
Am I doing something wrong? How can I make sure the app will function immediately after releasing the control button?

Risposte (2)

Mark Kamps
Mark Kamps il 12 Set 2023
Dear @Benjamin Kraus, sorry to tag you directly, but in the past you have helped me with a similar problem:
The above metioned thread also included this issue. You were able to help me in this thread, hence my 'cry for help' in this thread...
Is the described problem that is present in the app some sort of bug? Or is this intended behaviour? And if so, is there any way to get it to do what I want it to do?

Raj
Raj il 15 Set 2023
Hi Mark,
I understand that you are facing issues while designing your App. I was able to reproduce the issue you had and was able to understand your observations.
I have an alternate approach to your problem which works just fine and doesn’t have any issue.
Instead of KeyPressFcn, you can use KeyReleaseFcn and make the necessary changes in the code and the callbacks and you can go ahead with your project. This works without any issue and on pressing the ‘control’ key, the screen doesn’t freeze as it was before.
I've attached the file for your reference.
I hope this resolves your issue and you are able to proceed further!!
  2 Commenti
Mark Kamps
Mark Kamps il 15 Set 2023
Hi Raj,
Thank you for your reply!
Strange... I get no difference in functionality at all. The problem still persists with me.
I saw the attached Test2.mlapp file was created in 2023a. Can you confirm that, with the cursur on the object (so not in the panel), when the control button is released, your interactions are switched? So withouth moving the cursor out of screen you can directly change behaviour?
If so, it might seem that the issue is solved in 2023a?
Raj
Raj il 20 Set 2023
Hi Mark,
In R2023a, it works just as how you mentioned. The interactions switches after the control button is released, even when the cursor button is on the object.
You can try using the R2023a version and I hope your issue gets resolved.

Accedi per commentare.

Categorie

Scopri di più su Develop uifigure-Based Apps in Help Center e File Exchange

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by