Start cursor at the end of text in single-line text popups.

Fixed an error message being in lower-case.
This commit is contained in:
Aloshi 2014-06-15 12:55:30 -05:00
parent 71700bd0c9
commit 1df8e6555d
4 changed files with 16 additions and 1 deletions

View file

@ -174,6 +174,16 @@ void TextEditComponent::moveCursor(int amt)
onCursorChanged();
}
void TextEditComponent::setCursor(size_t pos)
{
if(pos == std::string::npos)
mCursor = mText.length();
else
mCursor = (int)pos;
moveCursor(0);
}
void TextEditComponent::onTextChanged()
{
std::string wrappedText = (isMultiline() ? mFont->wrapText(mText, getTextAreaSize().x()) : mText);

View file

@ -28,6 +28,8 @@ public:
inline bool isEditing() const { return mEditing; };
inline const std::shared_ptr<Font>& getFont() const { return mFont; }
void setCursor(size_t pos);
virtual std::vector<HelpPrompt> getHelpPrompts() override;
private:

View file

@ -138,7 +138,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, MetaDataList* md, const std::vector
if(mDeleteFunc)
{
auto deleteFileAndSelf = [&] { mDeleteFunc(); delete this; };
auto deleteBtnFunc = [this, deleteFileAndSelf] { mWindow->pushGui(new GuiMsgBox(mWindow, "This will delete a file!\nAre you sure?", "YES", deleteFileAndSelf, "NO", nullptr)); };
auto deleteBtnFunc = [this, deleteFileAndSelf] { mWindow->pushGui(new GuiMsgBox(mWindow, "THIS WILL DELETE A FILE!\nARE YOU SURE?", "YES", deleteFileAndSelf, "NO", nullptr)); };
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "DELETE", "delete", deleteBtnFunc));
}

View file

@ -15,6 +15,9 @@ GuiTextEditPopup::GuiTextEditPopup(Window* window, const std::string& title, con
mText = std::make_shared<TextEditComponent>(mWindow);
mText->setValue(initValue);
if(!multiLine)
mText->setCursor(initValue.size());
std::vector< std::shared_ptr<ButtonComponent> > buttons;
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, acceptBtnText, acceptBtnText, [this, okCallback] { okCallback(mText->getValue()); delete this; }));
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "CANCEL", "discard changes", [this] { delete this; }));