Why does QUESTDLG return the wrong button string if I use the TAB key to switch between different buttons and then hit the Return key using MATLAB 7.3 (R2006b)?

10 visualizaciones (últimos 30 días)
I would like to use the TAB key to switch between different buttons of a QUESTDLG.
At the moment I am only able to use the mouse to choose between the different buttons but not the TAB key. The buttons do get highlighted in order but when you hit the return key, the default selection is always returned.
For example:
ButtonName = questdlg('What is your favorite color?', ...
'Color Question', ...
'Red', 'Green', 'Blue', 'Green');
switch ButtonName,
case 'Red',
disp('Your favorite color is Red');
case 'Blue',
disp('Your favorite color is Blue.')
case 'Green',
disp('Your favorite color is Green.');
end
After executing the above code, pressing the TAB key causes different buttons to be highlighted but Green is always returned when you hit the return key.

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 3 de Sept. de 2009
The ability to use the TAB key to switch between different buttons on a QUESTDLG dialog and activating the button via return key is not available in MATLAB.
To work around this issue you can use the use the TAB key to switch between different buttons on a QUESTDLG dialog and hit the spacebar key to return the correct button string.
  2 comentarios
Walter Roberson
Walter Roberson el 2 de Ag. de 2015
Thierry Dalon comments "I would appreciate MathWorks fixing this issue - see my fix proposal in my answer."
Image Analyst
Image Analyst el 17 de Nov. de 2020
This has been fixed at some point. At least it's not a problem in R2020b.
ButtonName = questdlg('What is your favorite color?', ...
'Color Question', 'Red', 'Green', 'Blue', 'Green');
switch ButtonName
case 'Red'
disp('Your favorite color is Red');
case 'Blue'
disp('Your favorite color is Blue.')
case 'Green'
disp('Your favorite color is Green.');
end

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre App Building en Help Center y File Exchange.

Productos


Versión

R2006b

Community Treasure Hunt

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

Start Hunting!

Translated by