BartekW
Topic Author
Posts: 53
Joined: 24 Mar 2021, 14:33

Keyboard Navigation - how to make a tree of focusable input?

04 May 2021, 12:59

Hey, I want to make something like tree of views. I mean focus tabs hierarchy
-1MainTab
*1SubTab

-2MainTab
*1SubTab
*2SubTab

-3MainTab

Each SubTab generate content again in ContentControl, lets give it name="Content"
Each .xaml (with subtabs) is generated in ContentControl ("Content") when I focus any MainTab. And after enter I want to refocus input to the generated controls, in this case panel with subtabs. and go on.. Now we have focus on generated controls. When I focus one of subtab we should generate content in Content ("Content").
But when we click back we should focus controls in reverse direction. Its like a tree of focusable controls.
Any tips, any fast examples maybe? Please.

Tags:
 
BartekW
Topic Author
Posts: 53
Joined: 24 Mar 2021, 14:33

Re: Keyboard Navigation - how to make a tree of focusable input?

04 May 2021, 13:43

Maybe another question how to pass focus input to generated xaml in ContentControl and how to return focus input when click "Back"
 
User avatar
sfernandez
Site Admin
Posts: 2220
Joined: 22 Dec 2011, 19:20

Re: Keyboard Navigation - how to make a tree of focusable input?

05 May 2021, 10:22

As explained in viewtopic.php?f=3&t=2291 you can use SetFocusAction to focus an element of the generated content when it gets loaded.
Or you can use a State value in your view model that indicates which is the active content that has to get the focus. We did something like that in our Menu3D sample.
 
BartekW
Topic Author
Posts: 53
Joined: 24 Mar 2021, 14:33

Re: Keyboard Navigation - how to make a tree of focusable input?

05 May 2021, 10:59

Yes but in Menu3D sample here we change all views but i want to keep some focus scopes and switch between them. Like a focus tree. If I am in first focus (main) of the xaml I generated small UserControl and I want to pass Focus Scope to it and back on back button.
 
KeldorKatarn
Posts: 193
Joined: 30 May 2014, 10:26

Re: Keyboard Navigation - how to make a tree of focusable input?

05 May 2021, 11:04

@sfernandez

I'm not 100% sure if I understand the problem correctly, but could he mean what I recently suggested with that Custom/Extended FocusScope?
 
User avatar
sfernandez
Site Admin
Posts: 2220
Joined: 22 Dec 2011, 19:20

Re: Keyboard Navigation - how to make a tree of focusable input?

05 May 2021, 11:11

@BartekW
When you generate the small UserControl content, you should switch the state. Then the UserControl will react to that state change by setting the focus in whatever element the user control needs to. When navigating back, the state will change, so the main screen will react to that state change by setting the focus back to an element in the main screen.

@KeldorKatarn
Yes, when FocusScope is implemented I think it could help because you would be able to assign different focus scopes for each screen.
 
BartekW
Topic Author
Posts: 53
Joined: 24 Mar 2021, 14:33

Re: Keyboard Navigation - how to make a tree of focusable input?

05 May 2021, 12:34

@sfernandez
That sounds good but to be sure if ur solution fits in my idea. I would have 1 Main Menu on the screen and after focus on one of the buttons (Yep, on GotFocus event) I generate another menu below this menu. So now we have 2 menus 1 main menu and 1 submenu (generated) below in ContentControl. When I press Enter I want to switch focus from Main Menu to that generated menu. Is ViewModel correct solution for this yes? Just want to be sure we understand each other :)
Anyway thanks for help, thats a lot.
 
KeldorKatarn
Posts: 193
Joined: 30 May 2014, 10:26

Re: Keyboard Navigation - how to make a tree of focusable input?

05 May 2021, 12:43

Yes you want to do your navigation in a view model. THe button press should trigger a command.
 
BartekW
Topic Author
Posts: 53
Joined: 24 Mar 2021, 14:33

Re: Keyboard Navigation - how to make a tree of focusable input?

05 May 2021, 12:53

Yes you want to do your navigation in a view model. THe button press should trigger a command.
Thanks a lot :)
 
BartekW
Topic Author
Posts: 53
Joined: 24 Mar 2021, 14:33

Re: Keyboard Navigation - how to make a tree of focusable input?

05 May 2021, 13:40

Yes you want to do your navigation in a view model. THe button press should trigger a command.
I know u helped me a lot but maybe if u wanna make quickly code, even pseudocode with comments how View Model works? Just rly simple. I work in C++.

In Menu3D it works on enum but what if I will have 20 views here and I should use enums like view1, view2, view3..?

Who is online

Users browsing this forum: Bramboorek and 5 guests