Crafter.CppDOM/examples/InteractiveElement/main.cpp

16 lines
544 B
C++
Raw Permalink Normal View History

2025-11-09 22:43:52 +01:00
import Crafter.CppDOM;
import std;
using namespace Crafter;
2025-11-14 18:40:13 +01:00
HtmlElementPtr 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-14 18:40:13 +01:00
HtmlElementPtr button("myButton");
HtmlElementPtr output("output");
2025-11-09 22:43:52 +01:00
int main() {
2025-11-14 18:40:13 +01:00
button.AddClickListener([](Crafter::MouseEvent event){
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
});
}