Workaround to make sure message box remains on top (Fixes #4298)

0.6.3
scrawl 7 years ago
parent e2e48e0a50
commit 2caaa48b91
No known key found for this signature in database
GPG Key ID: 2E6CC3676024C402

@ -207,8 +207,6 @@ namespace MWGui
, mMessageBoxManager(parMessageBoxManager)
, mButtonPressed(-1)
{
setVisible(true);
int textPadding = 10; // padding between text-widget and main-widget
int textButtonPadding = 10; // padding between the text-widget und the button-widget
int buttonLeftPadding = 10; // padding between the buttons if horizontal
@ -358,7 +356,11 @@ namespace MWGui
mMessageWidget->setCoord(messageWidgetCoord);
}
// Set key focus to "Ok" button
setVisible(true);
}
MyGUI::Widget* InteractiveMessageBox::getDefaultKeyFocus()
{
std::vector<std::string> keywords { "sOk", "sYes" };
for(std::vector<MyGUI::Button*>::const_iterator button = mButtons.begin(); button != mButtons.end(); ++button)
{
@ -366,11 +368,11 @@ namespace MWGui
{
if(Misc::StringUtils::ciEqual(MyGUI::LanguageManager::getInstance().replaceTags("#{" + keyword + "}"), (*button)->getCaption()))
{
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(*button);
return;
return *button;
}
}
}
return NULL;
}
void InteractiveMessageBox::mousePressed (MyGUI::Widget* pressed)

@ -28,6 +28,8 @@ namespace MWGui
bool createInteractiveMessageBox (const std::string& message, const std::vector<std::string>& buttons);
bool isInteractiveMessageBox ();
const InteractiveMessageBox* getInteractiveMessageBox() const { return mInterMessageBoxe; }
/// Remove all message boxes
void clear();
@ -77,6 +79,8 @@ namespace MWGui
void mousePressed (MyGUI::Widget* _widget);
int readPressedButton ();
MyGUI::Widget* getDefaultKeyFocus() override;
virtual bool exit() { return false; }
bool mMarkedToDelete;

@ -874,6 +874,22 @@ namespace MWGui
window->onFrame(frameDuration);
}
// Make sure message boxes are always in front
// This is an awful workaround for a series of awfully interwoven issues that couldn't be worked around
// in a better way because of an impressive number of even more awfully interwoven issues.
if (mMessageBoxManager && mMessageBoxManager->isInteractiveMessageBox() && mCurrentModals.back() != mMessageBoxManager->getInteractiveMessageBox())
{
std::vector<WindowModal*>::iterator found = std::find(mCurrentModals.begin(), mCurrentModals.end(), mMessageBoxManager->getInteractiveMessageBox());
if (found != mCurrentModals.end())
{
WindowModal* msgbox = *found;
std::swap(*found, mCurrentModals.back());
MyGUI::InputManager::getInstance().addWidgetModal(msgbox->mMainWidget);
mKeyboardNavigation->setModalWindow(msgbox->mMainWidget);
mKeyboardNavigation->setDefaultFocus(msgbox->mMainWidget, msgbox->getDefaultKeyFocus());
}
}
if (!mCurrentModals.empty())
mCurrentModals.back()->onFrame(frameDuration);

Loading…
Cancel
Save