This commit is contained in:
Clement Roblot 2024-08-27 21:16:04 +07:00
parent 364993464a
commit 118055d942
2 changed files with 2 additions and 22 deletions

View File

@ -56,8 +56,6 @@ int main() {
// Tweak how the component tree is rendered:
auto renderer = Renderer(component, [&] {
textToCopy = screen.getSelection();
return vbox({
hbox(text(" First name : "), input_first_name->Render()),
hbox(text(" Last name : ") | selectable(), input_last_name->Render()),
@ -67,17 +65,10 @@ int main() {
text("Hello " + first_name + " " + last_name),
text("Your password is " + password),
text("Your phone number is " + phoneNumber),
// text("select_start " + std::to_string(selection.startx) + ";" + std::to_string(selection.starty)),
// text("select_end " + std::to_string(selection.endx) + ";" + std::to_string(selection.endy)),
text("textToCopy is " + textToCopy)
text("Selected test is " + screen.getSelection())
}) |
border; // | selectable([&textToCopy](std::string txtSelected){textToCopy = txtSelected;})
border;
});
// renderer |= CatchEvent([&](Event event) {
// return selectableCatchEvent(event);
// });
screen.Loop(renderer);
}

View File

@ -841,10 +841,6 @@ void ScreenInteractive::HandleTask(Component component, Task& task) {
bool ScreenInteractive::selectableCatchEvent(Event event) {
// std::ofstream MyFile("debug.log", std::ios_base::app);
// MyFile << "Top dog!" << std::endl;
// MyFile.close();
if (event.is_mouse()) {
auto& mouse = event.mouse();
if (mouse.button == Mouse::Left) {
@ -854,15 +850,12 @@ bool ScreenInteractive::selectableCatchEvent(Event event) {
selectedRegion.starty = mouse.y;
selectedRegion.endx = mouse.x;
selectedRegion.endy = mouse.y;
// refreshSelection();
} else if (mouse.motion == Mouse::Released) {
selectedRegion.endx = mouse.x;
selectedRegion.endy = mouse.y;
// refreshSelection();
} else if (mouse.motion == Mouse::Moved) {
selectedRegion.endx = mouse.x;
selectedRegion.endy = mouse.y;
// refreshSelection();
}
}
}
@ -887,10 +880,6 @@ void ScreenInteractive::refreshSelection(void) {
std::string ScreenInteractive::getSelection(void) {
// std::ofstream MyFile("debug.log", std::ios_base::app);
// MyFile << "Top dog!" << std::endl;
// MyFile.close();
return selectedText;
}