summaryrefslogtreecommitdiff
path: root/src/interface/Textbox.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/interface/Textbox.cpp')
-rw-r--r--src/interface/Textbox.cpp28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/interface/Textbox.cpp b/src/interface/Textbox.cpp
index 4916c64..8444b85 100644
--- a/src/interface/Textbox.cpp
+++ b/src/interface/Textbox.cpp
@@ -1,6 +1,7 @@
#include <string>
#include <iostream>
#include <stdexcept>
+#include <time.h>
#include "Config.h"
#include "interface/Point.h"
#include "interface/Textbox.h"
@@ -16,7 +17,8 @@ Textbox::Textbox(Point position, Point size, std::string textboxText, std::strin
border(true),
mouseDown(false),
limit(std::string::npos),
- inputType(All)
+ inputType(All),
+ keyDown(0)
{
placeHolder = textboxPlaceholder;
@@ -231,8 +233,32 @@ bool Textbox::CharacterValid(Uint16 character)
return false;
}
+void Textbox::Tick(float dt)
+{
+ Label::Tick(dt);
+ if((keyDown || characterDown) && repeatTime <= clock())
+ {
+ OnVKeyPress(keyDown, characterDown, false, false, false);
+ repeatTime = clock()+(0.03 * CLOCKS_PER_SEC);
+ }
+}
+
+void Textbox::OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt)
+{
+ keyDown = 0;
+ characterDown = 0;
+}
+
void Textbox::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
{
+ characterDown = character;
+ keyDown = key;
+ repeatTime = clock()+(0.3 * CLOCKS_PER_SEC);
+ OnVKeyPress(key, character, shift, ctrl, alt);
+}
+
+void Textbox::OnVKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
+{
bool changed = false;
if(ctrl && key == 'c' && !masked)
{