add 'onfocus' ui event & optimize container:add

This commit is contained in:
MihailRis
2025-04-26 20:16:57 +03:00
parent 8e8cabf2d1
commit 1e90115a26
9 changed files with 31 additions and 10 deletions
+6 -2
View File
@@ -63,7 +63,7 @@ static runnable create_runnable(
const std::string& name
) {
if (element.has(name)) {
std::string text = element.attr(name).getText();
const std::string& text = element.attr(name).getText();
if (!text.empty()) {
return scripting::create_runnable(
reader.getEnvironment(), text, reader.getFilename()
@@ -180,6 +180,10 @@ static void read_uinode(
node.listenAction(onclick);
}
if (auto onfocus = create_action(reader, element, "onfocus")) {
node.listenFocus(onfocus);
}
if (auto ondefocus = create_action(reader, element, "ondefocus")) {
node.listenDefocus(ondefocus);
}
@@ -761,7 +765,7 @@ static std::shared_ptr<UINode> read_iframe(
return iframe;
}
UiXmlReader::UiXmlReader(gui::GUI& gui, const scriptenv& env) : gui(gui), env(env) {
UiXmlReader::UiXmlReader(gui::GUI& gui, scriptenv&& env) : gui(gui), env(std::move(env)) {
contextStack.emplace("");
add("image", read_image);
add("canvas", read_canvas);