forked from teamnwah/openmw-tes3coop
Add an option to disable GUI keyboard navigation (Bug #4333)
This commit is contained in:
parent
870c658500
commit
e81faf5f2f
6 changed files with 34 additions and 1 deletions
|
@ -39,6 +39,7 @@ void getKeyFocusWidgets(MyGUI::Widget* parent, std::vector<MyGUI::Widget*>& resu
|
|||
KeyboardNavigation::KeyboardNavigation()
|
||||
: mCurrentFocus(nullptr)
|
||||
, mModalWindow(nullptr)
|
||||
, mEnabled(true)
|
||||
{
|
||||
MyGUI::WidgetManager::getInstance().registerUnlinker(this);
|
||||
}
|
||||
|
@ -101,6 +102,9 @@ bool isRootParent(MyGUI::Widget* widget, MyGUI::Widget* root)
|
|||
|
||||
void KeyboardNavigation::onFrame()
|
||||
{
|
||||
if (!mEnabled)
|
||||
return;
|
||||
|
||||
MyGUI::Widget* focus = MyGUI::InputManager::getInstance().getKeyFocusWidget();
|
||||
|
||||
if (focus == mCurrentFocus)
|
||||
|
@ -150,6 +154,11 @@ void KeyboardNavigation::setModalWindow(MyGUI::Widget *window)
|
|||
mModalWindow = window;
|
||||
}
|
||||
|
||||
void KeyboardNavigation::setEnabled(bool enabled)
|
||||
{
|
||||
mEnabled = enabled;
|
||||
}
|
||||
|
||||
enum Direction
|
||||
{
|
||||
D_Left,
|
||||
|
@ -162,6 +171,9 @@ enum Direction
|
|||
|
||||
bool KeyboardNavigation::injectKeyPress(MyGUI::KeyCode key, unsigned int text)
|
||||
{
|
||||
if (!mEnabled)
|
||||
return false;
|
||||
|
||||
switch (key.getValue())
|
||||
{
|
||||
case MyGUI::KeyCode::ArrowLeft:
|
||||
|
|
|
@ -28,6 +28,8 @@ namespace MWGui
|
|||
|
||||
void setModalWindow(MyGUI::Widget* window);
|
||||
|
||||
void setEnabled(bool enabled);
|
||||
|
||||
private:
|
||||
bool switchFocus(int direction, bool wrap);
|
||||
|
||||
|
@ -40,6 +42,8 @@ namespace MWGui
|
|||
|
||||
MyGUI::Widget* mCurrentFocus;
|
||||
MyGUI::Widget* mModalWindow;
|
||||
|
||||
bool mEnabled;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -237,7 +237,10 @@ namespace MWGui
|
|||
MyGUI::FactoryManager::getInstance().registerFactory<ResourceImageSetPointerFix>("Resource", "ResourceImageSetPointer");
|
||||
MyGUI::ResourceManager::getInstance().load("core.xml");
|
||||
|
||||
bool keyboardNav = Settings::Manager::getBool("keyboard navigation", "GUI");
|
||||
mKeyboardNavigation.reset(new KeyboardNavigation());
|
||||
mKeyboardNavigation->setEnabled(keyboardNav);
|
||||
Gui::ImageButton::setDefaultNeedKeyFocus(keyboardNav);
|
||||
|
||||
mLoadingScreen = new LoadingScreen(mResourceSystem->getVFS(), mViewer);
|
||||
mWindows.push_back(mLoadingScreen);
|
||||
|
|
|
@ -5,13 +5,20 @@
|
|||
namespace Gui
|
||||
{
|
||||
|
||||
bool ImageButton::sDefaultNeedKeyFocus = true;
|
||||
|
||||
ImageButton::ImageButton()
|
||||
: Base()
|
||||
, mMouseFocus(false)
|
||||
, mMousePress(false)
|
||||
, mKeyFocus(false)
|
||||
{
|
||||
setNeedKeyFocus(true);
|
||||
setNeedKeyFocus(sDefaultNeedKeyFocus);
|
||||
}
|
||||
|
||||
void ImageButton::setDefaultNeedKeyFocus(bool enabled)
|
||||
{
|
||||
sDefaultNeedKeyFocus = enabled;
|
||||
}
|
||||
|
||||
void ImageButton::setPropertyOverride(const std::string &_key, const std::string &_value)
|
||||
|
|
|
@ -18,12 +18,16 @@ namespace Gui
|
|||
|
||||
ImageButton();
|
||||
|
||||
static void setDefaultNeedKeyFocus(bool enabled);
|
||||
|
||||
/// Set mImageNormal, mImageHighlighted and mImagePushed based on file convention (image_idle.ext, image_over.ext and image_pressed.ext)
|
||||
void setImage(const std::string& image);
|
||||
|
||||
private:
|
||||
void updateImage();
|
||||
|
||||
static bool sDefaultNeedKeyFocus;
|
||||
|
||||
protected:
|
||||
virtual void setPropertyOverride(const std::string& _key, const std::string& _value);
|
||||
virtual void onMouseLostFocus(MyGUI::Widget* _new);
|
||||
|
|
|
@ -147,6 +147,9 @@ werewolf overlay = true
|
|||
color background owned = 0.15 0.0 0.0 1.0
|
||||
color crosshair owned = 1.0 0.15 0.15 1.0
|
||||
|
||||
# Controls whether Arrow keys, Movement keys, Tab/Shift-Tab and Spacebar/Enter/Activate may be used to navigate GUI buttons.
|
||||
keyboard navigation = true
|
||||
|
||||
[HUD]
|
||||
|
||||
# Displays the crosshair or reticle when not in GUI mode.
|
||||
|
|
Loading…
Reference in a new issue