added view

This commit is contained in:
Jorijn van der Graaf 2025-11-10 22:46:05 +01:00
commit 580e53d3bc
11 changed files with 68 additions and 34 deletions

View file

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