Clear Filters
Clear Filters

Change focus after tab selection in app designer

9 views (last 30 days)
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 Comments
LEMF
LEMF on 26 Oct 2023
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 on 26 Oct 2023
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!

Sign in to comment.

Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!