How do I make a uibutton the 'active' item in a GUI upon construction?

1 visualización (últimos 30 días)
I would like to have a button on an appDesigner GUI that is highlighted upon opening, giving the user the option of quickly dismissing the GUI by pressing the Enter Key or Spacebar.
If the GUI has the button as the first element, I can hit tab, then spacebar/enter to trigger the callback, but I would like a single keypress option. Does anyone know of a way to do this?
Thanks!

Respuesta aceptada

Kevin Holly
Kevin Holly el 23 de Jun. de 2023
Editada: Kevin Holly el 23 de Jun. de 2023
Below would work for R2022a and later.
You can add
focus(app.Button)
to the startup function. To add a startup function, click Callback on the toolstrip while in Code View.
  2 comentarios
Alan Bindemann
Alan Bindemann el 23 de Jun. de 2023
That's exactly what I need, but I am restricted to development in a version earlier than R2022a at the present time. Thanks for the reply though.
Cheers.
Kevin Holly
Kevin Holly el 23 de Jun. de 2023
Please see the link in the previous comment.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by