Matlab App Designer ginput bug

11 views (last 30 days)
Vicente Fernández Rodilla
Answered: Kumar Pallav on 25 Mar 2022
I am developing an App in Matlab App Designer, and I need to use ginput to detect if the user pressed an arrow button (left, right, up or down).
[gx, gy, button] = ginput(1) ;
switch button
case 28 %left arrow
%do some stuff
case 29 %right arrow
%do some stuff
case 30 %up arrow
%do some stuff
case 31 %down arrow
%do some stuff
%case ... (more stuff)
end
When I use this code in Matlab Command Window, it works as desired, but in Matlab App Designer, all arrow buttons are detected as ASCII character 65506 (¬), so there is no way to know what arrow button the user has pressed.
Can anyone help me? Am I doing something wrong?

Answers (1)

Kumar Pallav
Kumar Pallav on 25 Mar 2022
From the code you shared, the ASCII value of left arrow is mentioned as 28, however, it is actually 37. Similarly, up arrow ASCII value is 38. Could you please change the values and verify again.

Community Treasure Hunt

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

Start Hunting!