documentation
This commit is contained in:
parent
cb500f5eda
commit
3275eb2f70
135 changed files with 15649 additions and 430 deletions
49
example/HelloInput/README
Normal file
49
example/HelloInput/README
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
# HelloInput Example
|
||||
|
||||
## Description
|
||||
|
||||
This example demonstrates how to handle basic input events by:
|
||||
|
||||
- Create a window using `WindowWaylandWayland`
|
||||
- Register event listeners using `EventListener<T>` for:
|
||||
- Mouse click events
|
||||
- Specific key events
|
||||
- General keypress events
|
||||
- Print formatted feedback to the console when events are triggered
|
||||
|
||||
## Expected Result
|
||||
|
||||
When you interact with the window, you might see console output like:
|
||||
|
||||
Clicked on X:450 Y:320!
|
||||
Pressed specifically the a key!
|
||||
Pressed the b key!
|
||||
|
||||
Make sure that the window has focus.
|
||||
|
||||
## Highlighted Code Snippet
|
||||
|
||||
```cpp
|
||||
EventListener<MousePoint> clickListener(&window.onMouseLeftClick, [](MousePoint point){
|
||||
std::cout << std::format("Clicked on X:{} Y:{}!", point.x, point.y);
|
||||
});
|
||||
|
||||
EventListener<void> keyAListener(&window.onKeyDown['a'], [](){
|
||||
std::cout << std::format("Pressed specifically the a key!");
|
||||
});
|
||||
|
||||
EventListener<char> anyKeyListener(&window.onAnyKeyDown, [](char key){
|
||||
std::cout << std::format("Pressed the {} key!", key);
|
||||
});
|
||||
```
|
||||
|
||||
## How to Run
|
||||
|
||||
```bash
|
||||
crafter-build -c example -r
|
||||
```
|
||||
|
||||
## Relevant documentation
|
||||
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue