Crafter.CppDOM/examples/InteractiveElement/main.cpp

16 lines
604 B
C++
Raw Normal View History

2025-11-09 22:43:52 +01:00
import Crafter.CppDOM;
import std;
using namespace Crafter;
2025-11-10 22:46:05 +01:00
HtmlElementView body("body","<h1>Interactive Element Demo</h1>"
2025-11-09 22:43:52 +01:00
"<button id='myButton'>Click Me!</button>"
"<p id='output'>Click the button above</p>");
2025-11-10 22:46:05 +01:00
HtmlElementView* button = new HtmlElement("myButton"); //prevent destruction
2025-11-09 22:43:52 +01:00
int main() {
2025-11-10 21:31:06 +01:00
button->AddClickListener([](Crafter::MouseEvent event){
2025-11-10 22:46:05 +01:00
auto output = HtmlElementView("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
});
}