Parse mouse events.

This commit is contained in:
ArthurSonzogni
2021-04-18 18:32:38 +02:00
parent 476b9deaf8
commit cbd13499ae
6 changed files with 251 additions and 44 deletions

View File

@@ -6,11 +6,11 @@
namespace ftxui {
// static
Event Event::Character(const std::string& input) {
Event Event::Character(std::string input) {
Event event;
event.input_ = input;
event.is_character_ = true;
event.character_ = to_wstring(input)[0];
event.input_ = std::move(input);
event.type_ = Type::Character;
return event;
}
@@ -23,13 +23,67 @@ Event Event::Character(char c) {
Event Event::Character(wchar_t c) {
Event event;
event.input_ = {(char)c};
event.is_character_ = true;
event.type_ = Type::Character;
event.character_ = c;
return event;
}
// static
Event Event::Special(const std::string& input) {
Event Event::MouseMove(std::string input, int x, int y) {
Event event;
event.input_ = std::move(input);
event.type_ = Type::MouseMove;
event.mouse_ = {x, y};
return event;
}
// static
Event Event::MouseUp(std::string input, int x, int y) {
Event event;
event.input_ = std::move(input);
event.type_ = Type::MouseUp;
event.mouse_ = {x, y};
return event;
}
// static
Event Event::MouseLeftDown(std::string input, int x, int y) {
Event event;
event.input_ = std::move(input);
event.type_ = Type::MouseLeftDown;
event.mouse_ = {x, y};
return event;
}
// static
Event Event::MouseLeftMove(std::string input, int x, int y) {
Event event;
event.input_ = std::move(input);
event.type_ = Type::MouseLeftMove;
event.mouse_ = {x, y};
return event;
}
// static
Event Event::MouseRightDown(std::string input, int x, int y) {
Event event;
event.input_ = std::move(input);
event.type_ = Type::MouseRightDown;
event.mouse_ = {x, y};
return event;
}
// static
Event Event::MouseRightMove(std::string input, int x, int y) {
Event event;
event.input_ = std::move(input);
event.type_ = Type::MouseRightMove;
event.mouse_ = {x, y};
return event;
}
// static
Event Event::Special(std::string input) {
Event event;
event.input_ = std::move(input);
return event;