Crafter.CppDOM/examples/InputValueExample/main.cpp

16 lines
581 B
C++
Raw Normal View History

2025-11-12 16:36:52 +01:00
import Crafter.CppDOM;
import std;
using namespace Crafter;
2025-11-14 18:40:13 +01:00
HtmlElementPtr body("body", R"(<h1>Input GetValue() and SetValue() Example</h1><br><input id="input" type="text" placeholder="Enter your text here..."><br><button id="button">Change Value</button><p id ="valueOutput"></p>)");
HtmlElementPtr button("button");
HtmlElementPtr output("valueOutput");
HtmlElementPtr input("input");
2025-11-12 16:36:52 +01:00
int main(){
2025-11-14 18:40:13 +01:00
button.AddClickListener([](Crafter::MouseEvent) {
std::string newValue = input.GetValue();
output.SetInnerHTML(newValue);
input.SetValue("");
2025-11-12 16:36:52 +01:00
});
}