Skip to content

Commit

Permalink
ctrl+a support in Labels
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob1 committed Dec 18, 2015
1 parent 7620933 commit 76aeef2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
12 changes: 12 additions & 0 deletions src/gui/interface/Label.cpp
Expand Up @@ -233,6 +233,11 @@ void Label::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool al
{
copySelection();
}
if(ctrl && key == 'a')
{
selectAll();
return;
}
}

void Label::OnMouseMoved(int localx, int localy, int dx, int dy)
Expand Down Expand Up @@ -280,6 +285,13 @@ void Label::ClearSelection()
updateSelection();
}

void Label::selectAll()
{
selectionIndex0 = 0;
selectionIndex1 = text.length();
updateSelection();
}

void Label::updateSelection()
{
std::string currentText;
Expand Down
1 change: 1 addition & 0 deletions src/gui/interface/Label.h
Expand Up @@ -54,6 +54,7 @@ namespace ui

virtual bool HasSelection();
virtual void ClearSelection();
virtual void selectAll();
virtual void AutoHeight();

void SetTextColour(Colour textColour) { this->textColour = textColour; }
Expand Down
7 changes: 0 additions & 7 deletions src/gui/interface/Textbox.cpp
Expand Up @@ -182,13 +182,6 @@ void Textbox::cutSelection()
actionCallback->TextChangedCallback(this);
}

void Textbox::selectAll()
{
selectionIndex0 = 0;
selectionIndex1 = text.length();
updateSelection();
}

void Textbox::pasteIntoSelection()
{
std::string newText = format::CleanString(ClipboardPull(), true, true, inputType != Multiline, inputType == Number || inputType == Numeric);
Expand Down
1 change: 0 additions & 1 deletion src/gui/interface/Textbox.h
Expand Up @@ -69,7 +69,6 @@ class Textbox : public Label
std::string backingText;
std::string placeHolder;

virtual void selectAll();
virtual void cutSelection();
virtual void pasteIntoSelection();
};
Expand Down

0 comments on commit 76aeef2

Please sign in to comment.