We can catch mouse events

This commit is contained in:
Clement Roblot
2024-08-27 17:35:21 +07:00
committed by ArthurSonzogni
parent 75abd75b67
commit 1325256aa9
6 changed files with 71 additions and 4 deletions

View File

@@ -26,6 +26,15 @@ struct Event;
using Component = std::shared_ptr<ComponentBase>;
class ScreenInteractivePrivate;
typedef struct {
uint16_t startx = 0;
uint16_t endx = 0;
uint16_t starty = 0;
uint16_t endy = 0;
bool changed = false;
} Region;
class ScreenInteractive : public Screen {
public:
// Constructors:
@@ -82,6 +91,8 @@ class ScreenInteractive : public Screen {
void RunOnceBlocking(Component component);
void HandleTask(Component component, Task& task);
bool selectableCatchEvent(Event event);
std::string getSelection(void);
void Draw(Component component);
void ResetCursorPosition();
@@ -126,6 +137,8 @@ class ScreenInteractive : public Screen {
bool force_handle_ctrl_c_ = true;
bool force_handle_ctrl_z_ = true;
Region selectedRegion;
// The style of the cursor to restore on exit.
int cursor_reset_shape_ = 1;

View File

@@ -116,6 +116,9 @@ Element hyperlink(std::string link, Element child);
Element selectable(Element child);
Decorator selectable(void);
// -- Selection --
std::string getSelection(void);
// --- Layout is
// Horizontal, Vertical or stacked set of elements.
Element hbox(Elements);

View File

@@ -21,6 +21,7 @@ struct Pixel {
underlined(false),
underlined_double(false),
strikethrough(false),
selectable(false),
automerge(false) {}
// A bit field representing the style:
@@ -30,6 +31,7 @@ struct Pixel {
bool inverted : 1;
bool underlined : 1;
bool underlined_double : 1;
bool selectable : 1;
bool strikethrough : 1;
bool automerge : 1;