Make Enter on a name edit accept the dialog

pull/303/head
scrawl 7 years ago
parent 843106fc61
commit 8ae7e4c958

@ -54,9 +54,16 @@ namespace MWGui
mCreateButton->eventMouseButtonClick += MyGUI::newDelegate(this, &AlchemyWindow::onCreateButtonClicked); mCreateButton->eventMouseButtonClick += MyGUI::newDelegate(this, &AlchemyWindow::onCreateButtonClicked);
mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &AlchemyWindow::onCancelButtonClicked); mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &AlchemyWindow::onCancelButtonClicked);
mNameEdit->eventEditSelectAccept += MyGUI::newDelegate(this, &AlchemyWindow::onAccept);
center(); center();
} }
void AlchemyWindow::onAccept(MyGUI::EditBox* sender)
{
onCreateButtonClicked(sender);
}
void AlchemyWindow::onCancelButtonClicked(MyGUI::Widget* _sender) void AlchemyWindow::onCancelButtonClicked(MyGUI::Widget* _sender)
{ {
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Alchemy); MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Alchemy);
@ -128,6 +135,8 @@ namespace MWGui
} }
update(); update();
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mNameEdit);
} }
void AlchemyWindow::onIngredientSelected(MyGUI::Widget* _sender) void AlchemyWindow::onIngredientSelected(MyGUI::Widget* _sender)

@ -44,6 +44,7 @@ namespace MWGui
void onCancelButtonClicked(MyGUI::Widget* _sender); void onCancelButtonClicked(MyGUI::Widget* _sender);
void onCreateButtonClicked(MyGUI::Widget* _sender); void onCreateButtonClicked(MyGUI::Widget* _sender);
void onIngredientSelected(MyGUI::Widget* _sender); void onIngredientSelected(MyGUI::Widget* _sender);
void onAccept(MyGUI::EditBox*);
void onSelectedItem(int index); void onSelectedItem(int index);

@ -4,6 +4,7 @@
#include <MyGUI_Button.h> #include <MyGUI_Button.h>
#include <MyGUI_ScrollView.h> #include <MyGUI_ScrollView.h>
#include <MyGUI_EditBox.h>
#include <components/widgets/list.hpp> #include <components/widgets/list.hpp>
#include <components/settings/settings.hpp> #include <components/settings/settings.hpp>
@ -53,6 +54,7 @@ namespace MWGui
mSoulBox->eventMouseButtonClick += MyGUI::newDelegate(this, &EnchantingDialog::onSelectSoul); mSoulBox->eventMouseButtonClick += MyGUI::newDelegate(this, &EnchantingDialog::onSelectSoul);
mBuyButton->eventMouseButtonClick += MyGUI::newDelegate(this, &EnchantingDialog::onBuyButtonClicked); mBuyButton->eventMouseButtonClick += MyGUI::newDelegate(this, &EnchantingDialog::onBuyButtonClicked);
mTypeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &EnchantingDialog::onTypeButtonClicked); mTypeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &EnchantingDialog::onTypeButtonClicked);
mName->eventEditSelectAccept += MyGUI::newDelegate(this, &EnchantingDialog::onAccept);
} }
EnchantingDialog::~EnchantingDialog() EnchantingDialog::~EnchantingDialog()
@ -63,6 +65,7 @@ namespace MWGui
void EnchantingDialog::onOpen() void EnchantingDialog::onOpen()
{ {
center(); center();
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mName);
} }
void EnchantingDialog::setSoulGem(const MWWorld::Ptr &gem) void EnchantingDialog::setSoulGem(const MWWorld::Ptr &gem)
@ -284,6 +287,11 @@ namespace MWGui
updateEffectsView(); updateEffectsView();
} }
void EnchantingDialog::onAccept(MyGUI::EditBox *sender)
{
onBuyButtonClicked(sender);
}
void EnchantingDialog::onBuyButtonClicked(MyGUI::Widget* sender) void EnchantingDialog::onBuyButtonClicked(MyGUI::Widget* sender)
{ {
if (mEffects.size() <= 0) if (mEffects.size() <= 0)

@ -48,6 +48,7 @@ namespace MWGui
void onBuyButtonClicked(MyGUI::Widget* sender); void onBuyButtonClicked(MyGUI::Widget* sender);
void updateLabels(); void updateLabels();
void onTypeButtonClicked(MyGUI::Widget* sender); void onTypeButtonClicked(MyGUI::Widget* sender);
void onAccept(MyGUI::EditBox* sender);
ItemSelectionDialog* mItemSelectionDialog; ItemSelectionDialog* mItemSelectionDialog;
@ -60,7 +61,7 @@ namespace MWGui
MyGUI::Button* mTypeButton; MyGUI::Button* mTypeButton;
MyGUI::Button* mBuyButton; MyGUI::Button* mBuyButton;
MyGUI::TextBox* mName; MyGUI::EditBox* mName;
MyGUI::TextBox* mEnchantmentPoints; MyGUI::TextBox* mEnchantmentPoints;
MyGUI::TextBox* mCastCost; MyGUI::TextBox* mCastCost;
MyGUI::TextBox* mCharge; MyGUI::TextBox* mCharge;

@ -349,6 +349,7 @@ namespace MWGui
mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellCreationDialog::onCancelButtonClicked); mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellCreationDialog::onCancelButtonClicked);
mBuyButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellCreationDialog::onBuyButtonClicked); mBuyButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellCreationDialog::onBuyButtonClicked);
mNameEdit->eventEditSelectAccept += MyGUI::newDelegate(this, &SpellCreationDialog::onAccept);
setWidgets(mAvailableEffectsList, mUsedEffectsView); setWidgets(mAvailableEffectsList, mUsedEffectsView);
} }
@ -416,6 +417,11 @@ namespace MWGui
MWBase::Environment::get().getWindowManager()->removeGuiMode (GM_SpellCreation); MWBase::Environment::get().getWindowManager()->removeGuiMode (GM_SpellCreation);
} }
void SpellCreationDialog::onAccept(MyGUI::EditBox *sender)
{
onBuyButtonClicked(sender);
}
void SpellCreationDialog::onOpen() void SpellCreationDialog::onOpen()
{ {
center(); center();

@ -162,6 +162,7 @@ namespace MWGui
void onCancelButtonClicked (MyGUI::Widget* sender); void onCancelButtonClicked (MyGUI::Widget* sender);
void onBuyButtonClicked (MyGUI::Widget* sender); void onBuyButtonClicked (MyGUI::Widget* sender);
void onAccept(MyGUI::EditBox* sender);
virtual void notifyEffectsChanged (); virtual void notifyEffectsChanged ();

Loading…
Cancel
Save