kosenko / ui

Boost.UI library
266 stars 18 forks source link

Input event for text box base #23

Open UltraBlackLinux opened 1 year ago

UltraBlackLinux commented 1 year ago

Hey there, I noticed that it would be really useful, if the text_box_base actually had an input event using e.g. a uistring not only for consistency's sake, but also because it would be really useful. It would just allow to write code much easier with less problems like the following:

ui::string_box text(parent, "text");
text.on_edit([&](){somevar = std::stof(text.text().string());});

Which throws: libs/ui/src/text_box.cpp(102): assert ""impl"" failed in text(): Widget should be created (I have no clue what this means, maybe I'm just doing something stupid) I would be pretty pleased if you added this! Thanks!

kosenko commented 1 year ago

Each widget should be created before use, and each child widget should have a parent. Not created widget acts like initialized with nullptr pointer.

UltraBlackLinux commented 1 year ago

Each widget should be created before use, and each child widget should have a parent. Not created widget acts like initialized with nullptr pointer.

I just noticed that I copied that code part wrong. But my point still stands: An input even that already supplies the new text doesn't exist and would be really useful imo.

kosenko commented 1 year ago

Yes, it would be nice to have a custom event with text value.