Change focus after tab selection in app designer

조회 수: 13 (최근 30일)
Shae Morgan
Shae Morgan 2020년 9월 17일
댓글: LEMF 2023년 10월 26일
I'm workin in app designer, and have an app that has a tabgroup component with a corresponding selectionchanged callback function. I also have a windowskeypressfnc to allow hotkeys for specific buttons in the app once the tab is changed.
The issue I'm running into is that the hotkeys don't work after switching tabs (presumably because the focus is still on the tab). I've seen a few threads (e.g., here) on the issue of focus - but what I'm wondering is whether I can add a line of code to the selectionchanged callback function of the tab group to shift focus to the tab figure to allow the windowskeypressfnc to work appropriately? I've tried calling button functions and other attempts, but they don't seem to work.
Thinking something like:
function TabGroupSelectionChanged(app, event)
if strcmp(app.TabGroup.SelectedTab.Title,'specifictab')
end
%code to shift focus to something inside the tab to allow windowskeypressfcn to work.
%in GUIDE - UIcontrol would have done it.
else
end
end
  댓글 수: 11
LEMF
LEMF 2023년 10월 26일
I've found out to use the command 'focus(c)' and solves me a little more on my scope. On that comand 'c' stands for the uicontrol handle you want to keep the focus, which it'd be the "app.UITable". However, I have added a counter to increase the columns within the Key press function callback but it doesn't work, it seems as if the current object which is the app.UITable, keeps being on the original cell the one I clicked first, dispite the fact a 'tab' key is being press at least once. Anyone who knows how to solve?
LEMF
LEMF 2023년 10월 26일
Well, I have eventually solved, I'll quickly let it know here in case someone face the same issue like I was having. The reason is that you must increase the property 'Selection' one colum on yout app.UITable, which is what actually does the 'tab' key button on the keyboard on a well known software, and at the same time you must increase the property structure one columns as well (the porperty structure is a variable which I created to record the indices on the table cell selection and help to comunicate both callbacks, the callback to respond to any key press button and a callback which responds to cell selection). If you do like that it will work. Hope this helps anybody finds this. JesusChrist bless you all!

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by