Improvements to textbox, prevent selection loss on non modifying keypresses
This commit is contained in:
parent
d138b2de54
commit
011a65f793
@ -29,7 +29,7 @@ public:
|
||||
virtual void Draw(Simulation * sim, Brush * brush, ui::Point position){
|
||||
sim->ApplyDecorationPoint(position.X, position.Y, Red, Green, Blue, Alpha, decoMode, brush);
|
||||
}
|
||||
virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) {
|
||||
virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2, bool dragging) {
|
||||
sim->ApplyDecorationLine(position1.X, position1.Y, position2.X, position2.Y, Red, Green, Blue, Alpha, decoMode, brush);
|
||||
}
|
||||
virtual void DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) {
|
||||
|
@ -254,17 +254,21 @@ void Textbox::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
|
||||
{
|
||||
case KEY_HOME:
|
||||
cursor = 0;
|
||||
ClearSelection();
|
||||
break;
|
||||
case KEY_END:
|
||||
cursor = backingText.length();
|
||||
ClearSelection();
|
||||
break;
|
||||
case KEY_LEFT:
|
||||
if(cursor > 0)
|
||||
cursor--;
|
||||
ClearSelection();
|
||||
break;
|
||||
case KEY_RIGHT:
|
||||
if(cursor < backingText.length())
|
||||
cursor++;
|
||||
ClearSelection();
|
||||
break;
|
||||
case KEY_DELETE:
|
||||
if(HasSelection())
|
||||
@ -283,6 +287,7 @@ void Textbox::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
|
||||
backingText.erase(cursor, 1);
|
||||
changed = true;
|
||||
}
|
||||
ClearSelection();
|
||||
break;
|
||||
case KEY_BACKSPACE:
|
||||
if(HasSelection())
|
||||
@ -307,6 +312,7 @@ void Textbox::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
|
||||
}
|
||||
changed = true;
|
||||
}
|
||||
ClearSelection();
|
||||
break;
|
||||
}
|
||||
if(CharacterValid(character))
|
||||
@ -332,9 +338,9 @@ void Textbox::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
|
||||
}
|
||||
cursor++;
|
||||
changed = true;
|
||||
}
|
||||
ClearSelection();
|
||||
}
|
||||
}
|
||||
catch(std::out_of_range &e)
|
||||
{
|
||||
cursor = 0;
|
||||
@ -350,8 +356,8 @@ void Textbox::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
|
||||
if(!backingText.length())
|
||||
backingText = "0";
|
||||
}
|
||||
if(cursor >= backingText.length())
|
||||
cursor = backingText.length()-1;
|
||||
if(cursor > backingText.length())
|
||||
cursor = backingText.length();
|
||||
if(changed)
|
||||
{
|
||||
if(masked)
|
||||
|
Loading…
Reference in New Issue
Block a user