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,15 +2,15 @@ import Crafter.CppDOM;
import std;
using namespace Crafter;
HtmlElementView body("body","<h1>Interactive Element Demo</h1>"
HtmlElementPtr body("body","<h1>Interactive Element Demo</h1>"
"<button id='myButton'>Click Me!</button>"
"<p id='output'>Click the button above</p>");
HtmlElementView* button = new HtmlElement("myButton"); //prevent destruction
HtmlElementPtr button("myButton");
HtmlElementPtr output("output");
int main() {
button->AddClickListener([](Crafter::MouseEvent event){
auto output = HtmlElementView("output");
button.AddClickListener([](Crafter::MouseEvent event){
output.SetInnerHTML("Button was clicked at (" + std::to_string(event.clientX) + ", " + std::to_string(event.clientY) + ")!");
});
}