mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-20 08:11:32 +00:00
Restore the previous key focus widget when exiting modal dialog
This commit is contained in:
parent
bbafe1e456
commit
269094ba8d
3 changed files with 35 additions and 4 deletions
|
@ -67,14 +67,15 @@ WindowModal::WindowModal(const std::string& parLayout)
|
||||||
|
|
||||||
void WindowModal::onOpen()
|
void WindowModal::onOpen()
|
||||||
{
|
{
|
||||||
MyGUI::InputManager::getInstance ().addWidgetModal (mMainWidget);
|
// Order important. We need to save the key focus widget before its unset
|
||||||
MWBase::Environment::get().getWindowManager()->addCurrentModal(this); //Set so we can escape it if needed
|
MWBase::Environment::get().getWindowManager()->addCurrentModal(this); //Set so we can escape it if needed
|
||||||
|
MyGUI::InputManager::getInstance ().addWidgetModal (mMainWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowModal::onClose()
|
void WindowModal::onClose()
|
||||||
{
|
{
|
||||||
MyGUI::InputManager::getInstance ().removeWidgetModal (mMainWidget);
|
|
||||||
MWBase::Environment::get().getWindowManager()->removeCurrentModal(this);
|
MWBase::Environment::get().getWindowManager()->removeCurrentModal(this);
|
||||||
|
MyGUI::InputManager::getInstance ().removeWidgetModal (mMainWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
NoDrop::NoDrop(DragAndDrop *drag, MyGUI::Widget *widget)
|
NoDrop::NoDrop(DragAndDrop *drag, MyGUI::Widget *widget)
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include <MyGUI_Gui.h>
|
#include <MyGUI_Gui.h>
|
||||||
#include <MyGUI_ClipboardManager.h>
|
#include <MyGUI_ClipboardManager.h>
|
||||||
#include <MyGUI_RenderManager.h>
|
#include <MyGUI_RenderManager.h>
|
||||||
|
#include <MyGUI_WidgetManager.h>
|
||||||
|
|
||||||
#include <SDL_keyboard.h>
|
#include <SDL_keyboard.h>
|
||||||
#include <SDL_clipboard.h>
|
#include <SDL_clipboard.h>
|
||||||
|
@ -136,6 +137,7 @@ namespace MWGui
|
||||||
, mWorkQueue(workQueue)
|
, mWorkQueue(workQueue)
|
||||||
, mViewer(viewer)
|
, mViewer(viewer)
|
||||||
, mConsoleOnlyScripts(consoleOnlyScripts)
|
, mConsoleOnlyScripts(consoleOnlyScripts)
|
||||||
|
, mSaveKeyFocus(NULL)
|
||||||
, mCurrentModals()
|
, mCurrentModals()
|
||||||
, mHud(NULL)
|
, mHud(NULL)
|
||||||
, mMap(NULL)
|
, mMap(NULL)
|
||||||
|
@ -260,6 +262,8 @@ namespace MWGui
|
||||||
|
|
||||||
MyGUI::InputManager::getInstance().eventChangeKeyFocus += MyGUI::newDelegate(this, &WindowManager::onKeyFocusChanged);
|
MyGUI::InputManager::getInstance().eventChangeKeyFocus += MyGUI::newDelegate(this, &WindowManager::onKeyFocusChanged);
|
||||||
|
|
||||||
|
MyGUI::WidgetManager::getInstance().registerUnlinker(this);
|
||||||
|
|
||||||
// Create all cursors in advance
|
// Create all cursors in advance
|
||||||
createCursors();
|
createCursors();
|
||||||
onCursorChange(MyGUI::PointerManager::getInstance().getDefaultPointer());
|
onCursorChange(MyGUI::PointerManager::getInstance().getDefaultPointer());
|
||||||
|
@ -496,6 +500,8 @@ namespace MWGui
|
||||||
MyGUI::ClipboardManager::getInstance().eventClipboardChanged.clear();
|
MyGUI::ClipboardManager::getInstance().eventClipboardChanged.clear();
|
||||||
MyGUI::ClipboardManager::getInstance().eventClipboardRequested.clear();
|
MyGUI::ClipboardManager::getInstance().eventClipboardRequested.clear();
|
||||||
|
|
||||||
|
MyGUI::WidgetManager::getInstance().unregisterUnlinker(this);
|
||||||
|
|
||||||
delete mConsole;
|
delete mConsole;
|
||||||
delete mMessageBoxManager;
|
delete mMessageBoxManager;
|
||||||
delete mHud;
|
delete mHud;
|
||||||
|
@ -1608,6 +1614,12 @@ namespace MWGui
|
||||||
return mLoadingScreen;
|
return mLoadingScreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WindowManager::_unlinkWidget(MyGUI::Widget *widget)
|
||||||
|
{
|
||||||
|
if (widget == mSaveKeyFocus)
|
||||||
|
mSaveKeyFocus = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
bool WindowManager::getCursorVisible()
|
bool WindowManager::getCursorVisible()
|
||||||
{
|
{
|
||||||
return mCursorVisible;
|
return mCursorVisible;
|
||||||
|
@ -1818,6 +1830,17 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
if (!mCurrentModals.empty())
|
if (!mCurrentModals.empty())
|
||||||
mCurrentModals.top()->exit();
|
mCurrentModals.top()->exit();
|
||||||
|
|
||||||
|
if (mCurrentModals.empty())
|
||||||
|
MyGUI::InputManager::getInstance().setKeyFocusWidget(mSaveKeyFocus);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WindowManager::addCurrentModal(WindowModal *input)
|
||||||
|
{
|
||||||
|
if (mCurrentModals.empty())
|
||||||
|
mSaveKeyFocus = MyGUI::InputManager::getInstance().getKeyFocusWidget();
|
||||||
|
|
||||||
|
mCurrentModals.push(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::removeCurrentModal(WindowModal* input)
|
void WindowManager::removeCurrentModal(WindowModal* input)
|
||||||
|
@ -1827,6 +1850,9 @@ namespace MWGui
|
||||||
if(!mCurrentModals.empty())
|
if(!mCurrentModals.empty())
|
||||||
if(input == mCurrentModals.top())
|
if(input == mCurrentModals.top())
|
||||||
mCurrentModals.pop();
|
mCurrentModals.pop();
|
||||||
|
|
||||||
|
if (mCurrentModals.empty())
|
||||||
|
MyGUI::InputManager::getInstance().setKeyFocusWidget(mSaveKeyFocus);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::onVideoKeyPressed(MyGUI::Widget *_sender, MyGUI::KeyCode _key, MyGUI::Char _char)
|
void WindowManager::onVideoKeyPressed(MyGUI::Widget *_sender, MyGUI::KeyCode _key, MyGUI::Char _char)
|
||||||
|
|
|
@ -124,7 +124,7 @@ namespace MWGui
|
||||||
class JailScreen;
|
class JailScreen;
|
||||||
class KeyboardNavigation;
|
class KeyboardNavigation;
|
||||||
|
|
||||||
class WindowManager : public MWBase::WindowManager
|
class WindowManager : public MWBase::WindowManager, MyGUI::IUnlinkWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef std::pair<std::string, int> Faction;
|
typedef std::pair<std::string, int> Faction;
|
||||||
|
@ -142,6 +142,8 @@ namespace MWGui
|
||||||
|
|
||||||
virtual Loading::Listener* getLoadingScreen();
|
virtual Loading::Listener* getLoadingScreen();
|
||||||
|
|
||||||
|
void _unlinkWidget(MyGUI::Widget* widget);
|
||||||
|
|
||||||
/// @note This method will block until the video finishes playing
|
/// @note This method will block until the video finishes playing
|
||||||
/// (and will continually update the window while doing so)
|
/// (and will continually update the window while doing so)
|
||||||
virtual void playVideo(const std::string& name, bool allowSkipping);
|
virtual void playVideo(const std::string& name, bool allowSkipping);
|
||||||
|
@ -341,7 +343,7 @@ namespace MWGui
|
||||||
|
|
||||||
/// Sets the current Modal
|
/// Sets the current Modal
|
||||||
/** Used to send exit command to active Modal when Esc is pressed **/
|
/** Used to send exit command to active Modal when Esc is pressed **/
|
||||||
virtual void addCurrentModal(WindowModal* input) {mCurrentModals.push(input);}
|
virtual void addCurrentModal(WindowModal* input);
|
||||||
|
|
||||||
/// Removes the top Modal
|
/// Removes the top Modal
|
||||||
/** Used when one Modal adds another Modal
|
/** Used when one Modal adds another Modal
|
||||||
|
@ -404,6 +406,8 @@ namespace MWGui
|
||||||
MWWorld::Ptr mSelectedEnchantItem;
|
MWWorld::Ptr mSelectedEnchantItem;
|
||||||
MWWorld::Ptr mSelectedWeapon;
|
MWWorld::Ptr mSelectedWeapon;
|
||||||
|
|
||||||
|
MyGUI::Widget* mSaveKeyFocus;
|
||||||
|
|
||||||
std::stack<WindowModal*> mCurrentModals;
|
std::stack<WindowModal*> mCurrentModals;
|
||||||
|
|
||||||
// Markers placed manually by the player. Must be shared between both map views (the HUD map and the map window).
|
// Markers placed manually by the player. Must be shared between both map views (the HUD map and the map window).
|
||||||
|
|
Loading…
Reference in a new issue