diff --git a/src/dialogues/TextPrompt.cpp b/src/dialogues/TextPrompt.cpp index 85472a0da..dbaefd245 100644 --- a/src/dialogues/TextPrompt.cpp +++ b/src/dialogues/TextPrompt.cpp @@ -62,6 +62,7 @@ TextPrompt::TextPrompt(std::string title, std::string message, std::string text, } textField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; AddComponent(textField); + FocusComponent(textField); ui::Button * cancelButton = new ui::Button(ui::Point(0, Size.Y-16), ui::Point((Size.X/2)+1, 16), "Cancel"); cancelButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; diff --git a/src/game/PropertyTool.cpp b/src/game/PropertyTool.cpp index 811d10e9f..589740cf3 100644 --- a/src/game/PropertyTool.cpp +++ b/src/game/PropertyTool.cpp @@ -8,6 +8,7 @@ #include "interface/Label.h" #include "interface/Textbox.h" #include "interface/DropDown.h" +#include "interface/Keys.h" #include "dialogues/ErrorMessage.h" class PropertyWindow: public ui::Window @@ -23,6 +24,7 @@ public: PropertyWindow(PropertyTool * tool_, Simulation * sim_, ui::Point position_); void SetProperty(); virtual void OnDraw(); + virtual void OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt); virtual void OnTryExit(ExitMethod method); virtual ~PropertyWindow() {} class OkayAction: public ui::ButtonAction @@ -74,6 +76,7 @@ position(position_) textField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; textField->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; AddComponent(textField); + FocusComponent(textField); ui::Engine::Ref().ShowWindow(this); } @@ -207,6 +210,14 @@ void PropertyWindow::OnDraw() g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 200, 200, 200, 255); } +void PropertyWindow::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt) +{ + if (key == KEY_UP) + property->SetOption(property->GetOption().second-1); + else if (key == KEY_DOWN) + property->SetOption(property->GetOption().second+1); +} + void PropertyTool::Click(Simulation * sim, Brush * brush, ui::Point position) { new PropertyWindow(this, sim, position);