Added keyboard/controller controls for scrollable menu components beyond bounds for disabled controls.
This commit is contained in:
+20
-2
@@ -402,9 +402,19 @@ void Menu::KeyboardButtonNavigation(Crawler*game,vf2d menuPos){
|
||||
}
|
||||
if(prevSelection!=selection){
|
||||
if(selection!=vi2d{-1,-1}&&buttons[selection.y][selection.x]->disabled){
|
||||
selection=prevSelection;
|
||||
bool handled=false;
|
||||
if(!MOUSE_NAVIGATION){
|
||||
//Let's transfer some information about our selection being off the screen. Our intention with keyboard controls is that the screen will scroll to the correct location instead.
|
||||
//If we return false, then we handled it ourselves, no need to go back to the previous selection.
|
||||
if(HandleOutsideDisabledButtonSelection(buttons[selection.y][selection.x])){
|
||||
handled=true;
|
||||
}
|
||||
}
|
||||
if(!handled){
|
||||
// If the new selection of a button on this frame is disabled for some reason and we didn't handle it, we need to go back to what we had selected before.
|
||||
selection=prevSelection;
|
||||
}
|
||||
}
|
||||
// If the new selection of a button on this frame is disabled for some reason, we need to go back to what we had selected before.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -489,4 +499,12 @@ Pixel Menu::GetRenderColor(){
|
||||
col=WHITE*"ThemeGlobal.MenuUnfocusedColorMult"_F;
|
||||
}
|
||||
return col;
|
||||
}
|
||||
|
||||
bool Menu::HandleOutsideDisabledButtonSelection(MenuComponent*disabledButton){
|
||||
if(disabledButton->parentComponent!=nullptr){
|
||||
return disabledButton->parentComponent->HandleOutsideDisabledButtonSelection(disabledButton);
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user