mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-15 15:38:21 +08:00
Add mouse implementation of most components.
This commit is contained in:
@@ -25,6 +25,8 @@ class Button : public Component {
|
||||
// Component implementation.
|
||||
Element Render() override;
|
||||
bool OnEvent(Event) override;
|
||||
private:
|
||||
Box box_;
|
||||
};
|
||||
|
||||
} // namespace ftxui
|
||||
|
@@ -38,7 +38,11 @@ class CheckBox : public Component {
|
||||
bool OnEvent(Event) override;
|
||||
|
||||
private:
|
||||
bool OnMouseEvent(Event event);
|
||||
|
||||
int cursor_position = 0;
|
||||
Box box_;
|
||||
|
||||
};
|
||||
|
||||
} // namespace ftxui
|
||||
|
@@ -36,6 +36,9 @@ class Container : public Component {
|
||||
|
||||
int selected_ = 0;
|
||||
int* selector_ = nullptr;
|
||||
|
||||
private:
|
||||
bool OnMouseEvent(Event event);
|
||||
};
|
||||
|
||||
} // namespace ftxui
|
||||
|
@@ -59,6 +59,7 @@ struct Event {
|
||||
bool is_character() const { return type_ == Type::Character;}
|
||||
wchar_t character() const { return character_; }
|
||||
|
||||
bool is_mouse() const;
|
||||
bool is_mouse_left_down() const { return type_ == Type::MouseLeftDown; }
|
||||
bool is_mouse_left_move() const { return type_ == Type::MouseLeftMove; }
|
||||
bool is_mouse_middle_down() const { return type_ == Type::MouseMiddleDown; }
|
||||
@@ -74,6 +75,8 @@ struct Event {
|
||||
|
||||
bool operator==(const Event& other) const { return input_ == other.input_; }
|
||||
|
||||
void MoveMouse(int dx, int dy);
|
||||
|
||||
//--- State section ----------------------------------------------------------
|
||||
private:
|
||||
enum class Type {
|
||||
|
@@ -31,6 +31,11 @@ class Menu : public Component {
|
||||
// Component implementation.
|
||||
Element Render() override;
|
||||
bool OnEvent(Event) override;
|
||||
|
||||
private:
|
||||
bool OnMouseEvent(Event);
|
||||
|
||||
std::vector<Box> boxes_;
|
||||
};
|
||||
|
||||
} // namespace ftxui
|
||||
|
@@ -39,7 +39,9 @@ class RadioBox : public Component {
|
||||
bool OnEvent(Event) override;
|
||||
|
||||
private:
|
||||
bool OnMouseEvent(Event event);
|
||||
int cursor_position = 0;
|
||||
std::vector<Box> boxes_;
|
||||
};
|
||||
|
||||
} // namespace ftxui
|
||||
|
@@ -30,6 +30,10 @@ class Toggle : public Component {
|
||||
// Component implementation.
|
||||
Element Render() override;
|
||||
bool OnEvent(Event) override;
|
||||
|
||||
private:
|
||||
bool OnMouseEvent(Event event);
|
||||
std::vector<Box> boxes_;
|
||||
};
|
||||
|
||||
} // namespace ftxui
|
||||
|
Reference in New Issue
Block a user