Skip to content

Commit

Permalink
update doc/*/scripting/user-input.md
Browse files Browse the repository at this point in the history
  • Loading branch information
MihailRis committed Jan 7, 2025
1 parent df9c301 commit 0d17396
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions doc/en/scripting/user-input.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ input.add_callback("key:space", function ()
end)
```

You can also bind the function lifetime to the UI container instead of the HUD.
In that case, `input.add_callback` may be used until the `on_hud_open` is called.

```lua
input.add_callback("key:escape", function ()
print("NO")
return true -- prevents previously assigned functions from being called
end, document.root)
```

```python
input.get_mouse_pos() -> {int, int}
```
Expand Down
10 changes: 10 additions & 0 deletions doc/ru/scripting/user-input.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ input.add_callback("key:space", function ()
end)
```

Также можно привязать время жизни функции к UI контейнеру, вместо HUD.
В таком случае, `input.add_callback` можно использовать до вызова `on_hud_open`.

```lua
input.add_callback("key:escape", function ()
print("NO")
return true -- предотвращает вызов назначенных ранее функций
end, document.root)
```

```python
input.get_mouse_pos() -> {int, int}
```
Expand Down

0 comments on commit 0d17396

Please sign in to comment.