docs: add documentation for gint.getkey_opt()
This commit is contained in:
parent
3523a83bda
commit
430fe06adc
|
@ -57,6 +57,7 @@ The functions `getkey()`, `getkey_opt()`, `pollevent()` and `waitevent()` all re
|
|||
|
||||
```py
|
||||
getkey() -> key_event
|
||||
getkey_opt(opts: GETKEY_*, timeout_ms: int | None) -> key_event
|
||||
```
|
||||
|
||||
The function `getkey()` pauses the program until a key is pressed or repeated, and returns the associated event (which is always of type `KEYEV_DOWN` or `KEYEV_HOLD`). By default, only arrow keys are repeated, once after 400 ms, then every 40 ms.
|
||||
|
@ -79,7 +80,25 @@ elif ev.key == KEY_DOWN and pos < N-1:
|
|||
pos += 1 # Move one place down
|
||||
```
|
||||
|
||||
TODO: Mention `getkey_opt()`
|
||||
The function `getkey_opt()` generalizes `getkey()` and provides more options to customize its behavior. The `opts` parameter accepts a combination (sum) of options from the table below, and the parameter `timeout_ms`, when not `None`, specifies how long `getkey_opt()` should wait before returning a `KEYEV_NONE` event if nothing happens. The delay is specified in milliseconds but the actual resolution is about 7-8 ms.
|
||||
|
||||
| Option | `getkey()` | Description |
|
||||
|----------------------|------------|--------------------------------------------------|
|
||||
| GETKEY_MOD_SHIFT | Yes | SHIFT is a modifier key |
|
||||
| GETKEY_MOD_ALPHA | Yes | ALPHA is a modifier key |
|
||||
| GETKEY_BACKLIGHT | Yes | SHIFT+OPTN toggles display backlight |
|
||||
| GETKEY_MENU | Yes | MENU brings up the calculator's main menu |
|
||||
| GETKEY_REP_ARROWS | Yes | Repeats arrow keys when held |
|
||||
| GETKEY_REP_ALL | No | Repeats all keys when held |
|
||||
| GETKEY_REP_PROFILE | Yes* | Enable custom repeat delays |
|
||||
| GETKEY_FEATURES | Yes* | Enable custom global shortcuts |
|
||||
| GETKEY_MENU_DUPDATE | Yes | Update display after return to menu (fx-CG) |
|
||||
| GETKEY_MENU_EVENT | No | Send a `KEYEV_OSMENU` event after return to menu |
|
||||
| GETKEY_POWEROFF | Yes | SHIFT+AC/ON turns the calculator off |
|
||||
|
||||
`getkey()` is equivalent to `getkey_opt(opts, None)` where `opts` is the sum of all options that have "Yes" in the `getkey()` column above.
|
||||
|
||||
The two options `GETKEY_REP_PROFILE` and `GETKEY_FEATURES` are only useful when configured through other functions that are not yet available in PythonExtra.
|
||||
|
||||
### Reading keyboard events in real time
|
||||
|
||||
|
@ -384,7 +403,7 @@ The `.color_count` field indicates the number of colors in the palette, when the
|
|||
|
||||
The functions `dimage()` and `dsubimage()` work the same way as for black-and-white models; please see above.
|
||||
|
||||
As for black-and-white models, images can be converted into a Python format with fxconv. For instance with [`cg_image_puzzle.png`](../../ports/sh/examples/cg_image_puzzle.png)
|
||||
As for black-and-white models, images can be converted into a Python format with fxconv. For instance with [`cg_image_puzzle.png`](../../ports/sh/examples/cg_image_puzzle.png) (full encoding elided):
|
||||
|
||||
![](../../ports/sh/examples/cg_image_puzzle.png)
|
||||
|
||||
|
|
|
@ -59,6 +59,7 @@ Les fonctions `getkey()`, `getekey_opt()`, `pollevent()` et `waitevent()` renvoi
|
|||
|
||||
```py
|
||||
getkey() -> key_event
|
||||
getkey_opt(opts: GETKEY_*, timeout_ms: int | None) -> key_event
|
||||
```
|
||||
|
||||
La fonction `getkey()` met le programme en pause jusqu'à ce qu'une touche soit pressée ou répétée, et renvoie l'événement associé (qui est forcément de type `KEYEV_DOWN` ou `KEYEV_HOLD`). Par défaut, les seules touches qui sont répétées sont les touches directionnelles, une première fois après 400 ms, et ensuite toutes les 40 ms.
|
||||
|
@ -81,7 +82,25 @@ elif ev.key == KEY_DOWN and pos < N-1:
|
|||
pos += 1 # Descendre d'une position
|
||||
```
|
||||
|
||||
TODO: Parler de `getkey_opt()`
|
||||
La fonction `getkey_opt()` est une généralisation de `getkey()` qui donne accès à plus d'options pour personnaliser le comportement de la fonction. Le paramètre `opts` accepte une combinaison d'options dans le tableau ci-dessous, et le paramètre `timeout_ms`, quand il n'est pas `None`, spécifie au bout de combien de temps la fonction doit s'arrêter et renvoyer un événement de type `KEYEV_NONE` s'il n'y a aucune activité sur le clavier. Le délai est exprimé en millisecondes mais la précision réelle est de l'ordre de 7-8 ms.
|
||||
|
||||
| Option | `getkey()` | Description |
|
||||
|----------------------|------------|------------------------------------------------------------|
|
||||
| GETKEY_MOD_SHIFT | Oui | La touche SHIFT est un modifieur |
|
||||
| GETKEY_MOD_ALPHA | Oui | La touche ALPHA est un modifieur |
|
||||
| GETKEY_BACKLIGHT | Oui | SHIFT+OPTN allume/éteint le rétroéclairage |
|
||||
| GETKEY_MENU | Oui | MENU retourne au menu principal de la calculatrice |
|
||||
| GETKEY_REP_ARROWS | Oui | Répète les touches directionnelles si maintenues |
|
||||
| GETKEY_REP_ALL | Non | Répète toutes les touches si maintenues |
|
||||
| GETKEY_REP_PROFILE | Oui* | Personnalisation des durées de répétition |
|
||||
| GETKEY_FEATURES | Oui* | Personnalisation des raccourcis claviers globaux |
|
||||
| GETKEY_MENU_DUPDATE | Oui | Rafraîchit l'écran après un retour au menu (Prizm/G90) |
|
||||
| GETKEY_MENU_EVENT | Non | Envoie un événement `KEYEV_OSMENU` après un retour au menu |
|
||||
| GETKEY_POWEROFF | Oui | SHIFT+AC/ON éteint la calculatrice |
|
||||
|
||||
`getkey()` est équivalent à `getkey_opt(opts, None)` où `opts` est la somme de toutes les options marquées "Oui" dans la colonne `getkey()` ci-dessus.
|
||||
|
||||
Les deux options `GETKEY_REP_PROFILE` et `GETKEY_FEATURES` ne sont utiles qu'au travers de fonctions de configuration qui ne sont pour l'instant pas disponibles dans PythonExtra.
|
||||
|
||||
### Lecture des événements en temps réel
|
||||
|
||||
|
@ -385,7 +404,7 @@ Le champ `.color_count` indique le nombre de couleurs dans la palette quand il y
|
|||
|
||||
Les fonctions `dimage()` et `dsubimage()` ont le même fonctionnement que pour les Graph mono ; voir ci-dessus.
|
||||
|
||||
Comme pour Graph mono les images peuvent être converties avec fxconv. Par exemple pour l'image [`cg_image_puzzle.png`](../../ports/sh/examples/cg_image_puzzle.png)
|
||||
Comme pour Graph mono les images peuvent être converties avec fxconv. Par exemple pour l'image [`cg_image_puzzle.png`](../../ports/sh/examples/cg_image_puzzle.png) (code abrégé) :
|
||||
|
||||
![](../../ports/sh/examples/cg_image_puzzle.png)
|
||||
|
||||
|
|
Loading…
Reference in New Issue