Browse Source

Merge branch 'master' of https://github.com/VCVRack/Rack into 2017-10-bontric-midi-interface-revamp

tags/v0.4.0
ben 7 years ago
parent
commit
85fb2c66c1
2 changed files with 8 additions and 1 deletions
  1. +1
    -0
      include/widgets.hpp
  2. +7
    -1
      src/widgets/TextField.cpp

+ 1
- 0
include/widgets.hpp View File

@@ -411,6 +411,7 @@ struct TextField : OpaqueWidget {
bool onFocusKey(int scancode); bool onFocusKey(int scancode);
bool onFocus(); bool onFocus();
void insertText(std::string newText); void insertText(std::string newText);
virtual void onTextChange() {}
}; };


struct PasswordField : TextField { struct PasswordField : TextField {


+ 7
- 1
src/widgets/TextField.cpp View File

@@ -41,20 +41,25 @@ bool TextField::onFocusKey(int key) {
case GLFW_KEY_BACKSPACE: case GLFW_KEY_BACKSPACE:
if (begin < end) { if (begin < end) {
text.erase(begin, end - begin); text.erase(begin, end - begin);
onTextChange();
} }
else { else {
begin--; begin--;
if (begin >= 0)
if (begin >= 0) {
text.erase(begin, 1); text.erase(begin, 1);
onTextChange();
}
} }
end = begin; end = begin;
break; break;
case GLFW_KEY_DELETE: case GLFW_KEY_DELETE:
if (begin < end) { if (begin < end) {
text.erase(begin, end - begin); text.erase(begin, end - begin);
onTextChange();
} }
else { else {
text.erase(begin, 1); text.erase(begin, 1);
onTextChange();
} }
end = begin; end = begin;
break; break;
@@ -115,6 +120,7 @@ void TextField::insertText(std::string newText) {
text.insert(begin, newText); text.insert(begin, newText);
begin += newText.size(); begin += newText.size();
end = begin; end = begin;
onTextChange();
} }






Loading…
Cancel
Save