Crafter.CppDOM/examples/InteractiveElement/main.cpp

16 lines
592 B
C++
Raw Normal View History

2025-11-09 22:43:52 +01:00
import Crafter.CppDOM;
import std;
using namespace Crafter;
HtmlElement 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
int main() {
2025-11-10 21:31:06 +01:00
button->AddClickListener([](Crafter::MouseEvent event){
2025-11-09 22:43:52 +01:00
auto output = HtmlElement("output");
2025-11-10 21:31:06 +01:00
output.SetInnerHTML("Button was clicked at (" + std::to_string(event.clientX) + ", " + std::to_string(event.clientY) + ")!");
2025-11-09 22:43:52 +01:00
});
}