I just noticed that the keypress callback does not work when the app.cursor is enabled. So now my question is: How can I enable the keypress callback and the app.cursor at the same time?
keypress callback not working for a second called UIFigure
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Christian Mier
am 6 Feb. 2023
Beantwortet: Christian Mier
am 12 Feb. 2023
Hello, I have a UIFigure which opens a second UIFigure, but in this second UIFigure the keypress callback is not working. My app is very long so I just attached the code where the main UIfigures calls the other, the start function of the second UIfigure, and my keypress callback function. I already tried to focus on the figure with: figure(app.UIFigure), but it didn't work.
Thanks in advance.
%this code is in the main UIFigure
function goButtonPushed(app, event)
app.GraficasWindow = Graficas(app,app.OscCh,app.magnitudes); %Graficas is the name of my second uiFigure
end
%this is the starting function of second UIFIgure
function startupFcn(app, PDatorWindow, OscCh, magnitudes)
%bunch of other irrelevant things
end
%and this is the callback function
function UIFigureKeyPress(app, event)
key = event.Key;
display(key)
end
Akzeptierte Antwort
Weitere Antworten (1)
Jasvin
am 10 Feb. 2023
A possible workaround for this can be trying to change the focus to a UI element that’s within the second UI Figure via the focus() method (https://www.mathworks.com/help/matlab/ref/matlab.ui.figure.focus.html?s_tid=doc_ta). And from here you can try out options like setting the active figure via figure(app.UIFigure) again or if it's feasible, change the KeyPress callback from the UI Figure to this UI component that’s within the second UI Figure.
Siehe auch
Kategorien
Mehr zu Develop uifigure-Based Apps finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!