Autofocus first element?

May 29, 2009 at 11:04 AM

Hi,

first of all, I've looked into your menu system a bit, and I really like it :)
(and it looks like it fits the needs of our University project :))) )

A nice feature would be though, if the first selectable element is automatically focused when entering a page.
To get the idea:

One has a splash screen with a button "press start" in order to determine which gamepad is used by the player.
Currently one must move the cursor up or down, and then press start.

I've hacked a way in by commenting out these lines:

            // Check for cursor movement
            //if (input.CursorPos.X != lastInput.CursorPos.X || input.CursorPos.Y != lastInput.CursorPos.Y)
            //{
            //    MenuItem hoverItem = ClickTest(input.CursorPos);
            //    if (hoverItem != null && hoverItem.CanHaveFocus)
            //        FocusedItem = hoverItem;
            //    else
            //        FocusedItem = null;

            //}
            //else

of the class MenuProject.cs and in MainMenuComponent, by setting the focused item via

mainMenu.FocusedItem = mainMenu.GetMenuItemByName<Button>( "OptionsButton" );

at the end of the LoadContent method.

 

Of course this only works the first time, which leads to the following questions:
1) Is there a way to register for something like a OnPageChanged event?
2) Or might you consider implementing the auto focus first element feature?

 

Thanks in advance for any response :)

Chris