1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-05 15:55:45 +00:00
OpenMW/apps/openmw/mwgui/textinput.cpp

74 lines
2.1 KiB
C++
Raw Normal View History

#include "textinput.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwbase/environment.hpp"
2013-04-17 22:56:48 +00:00
namespace MWGui
{
2013-04-17 22:56:48 +00:00
TextInputDialog::TextInputDialog()
: WindowModal("openmw_text_input.layout")
{
// Centre dialog
center();
2013-04-17 22:56:48 +00:00
getWidget(mTextEdit, "TextEdit");
mTextEdit->eventEditSelectAccept += newDelegate(this, &TextInputDialog::onTextAccepted);
2013-04-17 22:56:48 +00:00
MyGUI::Button* okButton;
getWidget(okButton, "OKButton");
okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TextInputDialog::onOkClicked);
2013-04-17 22:56:48 +00:00
// Make sure the edit box has focus
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mTextEdit);
2013-04-17 22:56:48 +00:00
}
2013-04-17 22:56:48 +00:00
void TextInputDialog::setNextButtonShow(bool shown)
{
MyGUI::Button* okButton;
getWidget(okButton, "OKButton");
2013-04-17 22:56:48 +00:00
if (shown)
okButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sNext", ""));
else
okButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sOK", ""));
}
2013-04-17 22:56:48 +00:00
void TextInputDialog::setTextLabel(const std::string &label)
{
setText("LabelT", label);
}
void TextInputDialog::open()
{
WindowModal::open();
// Make sure the edit box has focus
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mTextEdit);
2013-04-17 22:56:48 +00:00
}
2013-04-17 22:56:48 +00:00
// widget controls
2013-04-17 22:56:48 +00:00
void TextInputDialog::onOkClicked(MyGUI::Widget* _sender)
{
2013-04-17 22:56:48 +00:00
if (mTextEdit->getCaption() == "")
{
MWBase::Environment::get().getWindowManager()->messageBox ("#{sNotifyMessage37}");
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget (mTextEdit);
2013-04-17 22:56:48 +00:00
}
else
eventDone(this);
}
2013-04-17 22:56:48 +00:00
void TextInputDialog::onTextAccepted(MyGUI::Edit* _sender)
{
2013-04-17 22:56:48 +00:00
if (mTextEdit->getCaption() == "")
{
MWBase::Environment::get().getWindowManager()->messageBox ("#{sNotifyMessage37}");
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget (mTextEdit);
2013-04-17 22:56:48 +00:00
}
else
eventDone(this);
}
2013-04-17 22:56:48 +00:00
}