better README
This commit is contained in:
parent
a9667d38fd
commit
7350ce0bea
4 changed files with 142 additions and 19 deletions
|
|
@ -5,13 +5,11 @@ This example demonstrates how to use DOM event handling with Crafter.CppDOM.
|
|||
## Features
|
||||
|
||||
- Shows how to create interactive UI elements using C++
|
||||
- Demonstrates the framework for attaching event listeners
|
||||
- Illustrates the planned callback mechanism for event handling
|
||||
- Demonstrates the event listener framework for attaching callbacks
|
||||
- Illustrates how to respond to user interactions
|
||||
|
||||
## Usage
|
||||
|
||||
The library now provides the foundation for interactive web applications:
|
||||
|
||||
```cpp
|
||||
import Crafter.CppDOM;
|
||||
using namespace Crafter::CppDOM;
|
||||
|
|
@ -25,15 +23,22 @@ int main(){
|
|||
|
||||
// Attach event listener
|
||||
HtmlElement button("myButton");
|
||||
button.AddEventListener("click");
|
||||
|
||||
// Future: button.OnClick([]() {
|
||||
// HtmlElement output("output");
|
||||
// output.SetInnerHTML("Button was clicked!");
|
||||
// });
|
||||
button.AddClickListener([]() {
|
||||
HtmlElement output("output");
|
||||
output.SetInnerHTML("Button was clicked!");
|
||||
});
|
||||
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
Note: The full callback mechanism requires additional infrastructure to properly bridge between JavaScript events and C++ callbacks. This implementation provides the framework for future development.
|
||||
## Building and Running
|
||||
|
||||
```bash
|
||||
crafter-build build executable
|
||||
run.sh
|
||||
```
|
||||
|
||||
Then navigate to `http://localhost:8080/` in your browser.
|
||||
|
||||
If caddy is not installed, you can use your favorite static file server instead.
|
||||
Loading…
Add table
Add a link
Reference in a new issue