Matlab App Designer ginput bug

조회 수: 4 (최근 30일)
Vicente Fernández Rodilla
Vicente Fernández Rodilla 2022년 2월 3일
댓글: Christopher 2023년 4월 26일
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)
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?
  댓글 수: 1
Christopher 2023년 4월 26일
I am also experiencing this bug. I experimentally determined that 28, 29, 30, 31 are left/right/up/down using ginput outside of app designer. It seems like MATLAB just uses some seldom-used separator characters' ascii values to handle the arrow keys, as there are not arrow keys in ascii.
For now, I'm getting the functionality I want from WASD keys, but I wish that the arrow keys worked.

댓글을 달려면 로그인하십시오.

답변 (1개)

Kumar Pallav
Kumar Pallav 2022년 3월 25일
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.


Help CenterFile Exchange에서 Specifying Target for Graphics Output에 대해 자세히 알아보기




Community Treasure Hunt

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

Start Hunting!

Translated by