Skip to content

Commit 1df8e65

Browse files
committed
Start cursor at the end of text in single-line text popups.
Fixed an error message being in lower-case.
1 parent 71700bd commit 1df8e65

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

src/components/TextEditComponent.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,16 @@ void TextEditComponent::moveCursor(int amt)
174174
onCursorChanged();
175175
}
176176

177+
void TextEditComponent::setCursor(size_t pos)
178+
{
179+
if(pos == std::string::npos)
180+
mCursor = mText.length();
181+
else
182+
mCursor = (int)pos;
183+
184+
moveCursor(0);
185+
}
186+
177187
void TextEditComponent::onTextChanged()
178188
{
179189
std::string wrappedText = (isMultiline() ? mFont->wrapText(mText, getTextAreaSize().x()) : mText);

src/components/TextEditComponent.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ class TextEditComponent : public GuiComponent
2828
inline bool isEditing() const { return mEditing; };
2929
inline const std::shared_ptr<Font>& getFont() const { return mFont; }
3030

31+
void setCursor(size_t pos);
32+
3133
virtual std::vector<HelpPrompt> getHelpPrompts() override;
3234

3335
private:

src/guis/GuiMetaDataEd.cpp

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

src/guis/GuiTextEditPopup.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ GuiTextEditPopup::GuiTextEditPopup(Window* window, const std::string& title, con
1515
mText = std::make_shared<TextEditComponent>(mWindow);
1616
mText->setValue(initValue);
1717

18+
if(!multiLine)
19+
mText->setCursor(initValue.size());
20+
1821
std::vector< std::shared_ptr<ButtonComponent> > buttons;
1922
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, acceptBtnText, acceptBtnText, [this, okCallback] { okCallback(mText->getValue()); delete this; }));
2023
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "CANCEL", "discard changes", [this] { delete this; }));

0 commit comments

Comments
 (0)