lifecycle update

This commit is contained in:
Jorijn van der Graaf 2025-11-14 18:40:13 +01:00
commit 0b7a43efbd
14 changed files with 950 additions and 490 deletions

View file

@ -2,16 +2,15 @@ import Crafter.CppDOM;
import std;
using namespace Crafter;
HtmlElement* body = new HtmlElement("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>)");
HtmlElement* button = new HtmlElement("button");
HtmlElement* output = new HtmlElement("valueOutput");
HtmlElement* input = new HtmlElement("input");
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");
int main(){
button->AddClickListener([](Crafter::MouseEvent) {
std::string newValue = input->GetValue();
output->SetInnerHTML(newValue);
input->SetValue("");
button.AddClickListener([](Crafter::MouseEvent) {
std::string newValue = input.GetValue();
output.SetInnerHTML(newValue);
input.SetValue("");
});
}