![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1417839/image.png)
How do I make a uibutton the 'active' item in a GUI upon construction?
조회 수: 5 (최근 30일)
이전 댓글 표시
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!
댓글 수: 0
채택된 답변
Kevin Holly
2023년 6월 23일
편집: Kevin Holly
2023년 6월 23일
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1417839/image.png)
댓글 수: 2
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!