2013-08-18 14:16:11 +00:00
|
|
|
#include "TextEditComponent.h"
|
|
|
|
#include "../Log.h"
|
|
|
|
|
|
|
|
TextEditComponent::TextEditComponent(Window* window) : GuiComponent(window),
|
|
|
|
mBox(window, 0, 0, 0, 0)
|
|
|
|
{
|
|
|
|
addChild(&mBox);
|
|
|
|
|
|
|
|
onFocusLost();
|
|
|
|
|
|
|
|
setSize(48, 22);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TextEditComponent::onFocusGained()
|
|
|
|
{
|
|
|
|
mBox.setHorizontalImage(":/glow_hor.png");
|
|
|
|
mBox.setVerticalImage(":/glow_vert.png");
|
|
|
|
mBox.setBorderColor(0x51CCFFFF);
|
2013-08-19 14:05:30 +00:00
|
|
|
|
|
|
|
SDL_StartTextInput();
|
2013-08-18 14:16:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TextEditComponent::onFocusLost()
|
|
|
|
{
|
|
|
|
mBox.setHorizontalImage(":/glow_off_hor.png");
|
|
|
|
mBox.setVerticalImage(":/glow_off_vert.png");
|
|
|
|
mBox.setBorderColor(0xFFFFFFFF);
|
2013-08-19 14:05:30 +00:00
|
|
|
|
|
|
|
SDL_StopTextInput();
|
2013-08-18 14:16:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TextEditComponent::onSizeChanged()
|
|
|
|
{
|
|
|
|
mBox.setSize(mSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TextEditComponent::setValue(const std::string& val)
|
|
|
|
{
|
|
|
|
mText = val;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string TextEditComponent::getValue() const
|
|
|
|
{
|
|
|
|
return mText;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TextEditComponent::input(InputConfig* config, Input input)
|
|
|
|
{
|
|
|
|
return GuiComponent::input(config, input);
|
|
|
|
}
|