unsigned short UiObjectQuantityPicker::GetQuantity(void) const
{
  Rocket::Controls::ElementFormControl* control = reinterpret_cast<Rocket::Controls::ElementFormControl*>(_line_edit);
  Rocket::Core::String                  string = control->GetValue();
  std::stringstream                     stream;
  unsigned short                        amount;

  stream << string.CString();
  stream >> amount;
  return (amount);
}
void UiObjectQuantityPicker::Accepted(Rocket::Core::Event&)
{
  Rocket::Controls::ElementFormControl* control = reinterpret_cast<Rocket::Controls::ElementFormControl*>(_line_edit);
  Rocket::Core::String                  string = control->GetValue();
  std::stringstream                     stream;
  unsigned short                        amount;

  stream << string.CString();
  stream >> amount;
  if (amount <= _max_quantity)
  {
    QuantityPicked.Emit(amount);
    Hide();
  }
}
示例#3
0
void Console::ProcessEvent(Rocket::Core::Event& event)
{
    String controlId(event.GetCurrentElement()->GetId().CString());
    if (controlId == "cmd")
    {
        int key = event.GetParameters()->Get<int>("key_identifier", 0);
        Rocket::Controls::ElementFormControl* inputBox =
            static_cast<Rocket::Controls::ElementFormControl*>(event.GetCurrentElement());
        if (key == Rocket::Core::Input::KI_RETURN)
        {
            String command = inputBox->GetValue().CString();
            inputBox->SetValue("");
            Execute(command);
        }
    }
}