summaryrefslogtreecommitdiff
path: root/src/interface/Textbox.cpp
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-01-30 00:40:28 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-01-30 00:40:28 (GMT)
commit259fc2bcf75d754af043a5d3fa39b6ee0c0b1dec (patch)
treef0fe2c14499345121371bba0ecc3fe21d17e0953 /src/interface/Textbox.cpp
parentfe329e9127ebcb8c89c505c4c120e175810d280c (diff)
downloadpowder-259fc2bcf75d754af043a5d3fa39b6ee0c0b1dec.zip
powder-259fc2bcf75d754af043a5d3fa39b6ee0c0b1dec.tar.gz
ASCII for key events, save and Textarea (no caret, yet)
Diffstat (limited to 'src/interface/Textbox.cpp')
-rw-r--r--src/interface/Textbox.cpp54
1 files changed, 13 insertions, 41 deletions
diff --git a/src/interface/Textbox.cpp b/src/interface/Textbox.cpp
index 328ccb5..1a54992 100644
--- a/src/interface/Textbox.cpp
+++ b/src/interface/Textbox.cpp
@@ -9,19 +9,6 @@
using namespace ui;
-Textbox::Textbox(Window* parent_state, std::string textboxText):
- Component(parent_state),
- text(textboxText),
- textPosition(ui::Point(0, 0)),
- textVAlign(AlignMiddle),
- textHAlign(AlignCentre),
- actionCallback(NULL),
- masked(false)
-{
- TextPosition();
- cursor = text.length();
-}
-
Textbox::Textbox(Point position, Point size, std::string textboxText):
Component(position, size),
text(textboxText),
@@ -35,19 +22,6 @@ Textbox::Textbox(Point position, Point size, std::string textboxText):
cursor = text.length();
}
-Textbox::Textbox(std::string textboxText):
- Component(),
- text(textboxText),
- textPosition(ui::Point(0, 0)),
- textVAlign(AlignMiddle),
- textHAlign(AlignCentre),
- actionCallback(NULL),
- masked(false)
-{
- TextPosition();
- cursor = text.length();
-}
-
Textbox::~Textbox()
{
if(actionCallback)
@@ -105,7 +79,7 @@ std::string Textbox::GetText()
return text;
}
-void Textbox::OnKeyPress(int key, bool shift, bool ctrl, bool alt)
+void Textbox::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
{
bool changed = false;
try
@@ -152,22 +126,20 @@ void Textbox::OnKeyPress(int key, bool shift, bool ctrl, bool alt)
changed = true;
}
break;
- default:
- if(key >= ' ' && key < 127)
+ }
+ if(character >= ' ' && character < 127)
+ {
+ if(cursor == text.length())
{
- if(cursor == text.length())
- {
- text += key;
- //std::cout << key << std::endl;
- }
- else
- {
- text.insert(cursor, 1, (char)key);
- }
- cursor++;
- changed = true;
+ text += character;
+ //std::cout << key << std::endl;
}
- break;
+ else
+ {
+ text.insert(cursor, 1, (char)character);
+ }
+ cursor++;
+ changed = true;
}
if(changed && actionCallback)
{