Workaround key focus being reset in BookWindow when next/prev are hidden

new-script-api
scrawl 7 years ago
parent c88c535e0e
commit 2514cc5cc8

@ -1,6 +1,7 @@
#include "bookwindow.hpp" #include "bookwindow.hpp"
#include <MyGUI_TextBox.h> #include <MyGUI_TextBox.h>
#include <MyGUI_InputManager.h>
#include <components/esm/loadbook.hpp> #include <components/esm/loadbook.hpp>
@ -153,20 +154,16 @@ namespace MWGui
mLeftPageNumber->setCaption( MyGUI::utility::toString(mCurrentPage*2 + 1) ); mLeftPageNumber->setCaption( MyGUI::utility::toString(mCurrentPage*2 + 1) );
mRightPageNumber->setCaption( MyGUI::utility::toString(mCurrentPage*2 + 2) ); mRightPageNumber->setCaption( MyGUI::utility::toString(mCurrentPage*2 + 2) );
//If it is the last page, hide the button "Next Page" MyGUI::Widget* focus = MyGUI::InputManager::getInstance().getKeyFocusWidget();
if ( (mCurrentPage+1)*2 == mPages.size() bool nextPageVisible = (mCurrentPage+1)*2 < mPages.size();
|| (mCurrentPage+1)*2 == mPages.size() + 1) mNextPageButton->setVisible(nextPageVisible);
{ bool prevPageVisible = mCurrentPage != 0;
mNextPageButton->setVisible(false); mPrevPageButton->setVisible(prevPageVisible);
} else {
mNextPageButton->setVisible(true); if (focus == mNextPageButton && !nextPageVisible && prevPageVisible)
} MyGUI::InputManager::getInstance().setKeyFocusWidget(mPrevPageButton);
//If it is the fist page, hide the button "Prev Page" else if (focus == mPrevPageButton && !prevPageVisible && nextPageVisible)
if (mCurrentPage == 0) { MyGUI::InputManager::getInstance().setKeyFocusWidget(mNextPageButton);
mPrevPageButton->setVisible(false);
} else {
mPrevPageButton->setVisible(true);
}
if (mPages.empty()) if (mPages.empty())
return; return;

Loading…
Cancel
Save