Add a way for midend_process_key() to report whether it handled a keypress

This adds a new bool * argument, which can be NULL if front ends don't
care whether the keypress was handled.  Currently they all do that.

Currently, "undo" and "redo" keys are treated as not handled if there's
no move to undo or redo.  This may be a little too strict.
This commit is contained in:
Ben Harris
2022-11-05 16:05:39 +00:00
parent 4fdcc54975
commit 4a37f7cf78
8 changed files with 50 additions and 35 deletions

View File

@ -3131,7 +3131,7 @@ call to this function. Some back ends require that \cw{midend_size()}
\H{midend-process-key} \cw{midend_process_key()}
\c bool midend_process_key(midend *me, int x, int y, int button);
\c bool midend_process_key(midend *me, int x, int y, int button, bool *handled);
The front end calls this function to report a mouse or keyboard event.
The parameters \c{x} and \c{y} are identical to the ones passed to the
@ -3173,6 +3173,12 @@ the effect of the keypress was to request termination of the program.
A front end should shut down the puzzle in response to a \cw{false}
return.
If the front end passes in a non-NULL pointer in \c{handled}, the
mid-end will set \cw{*handled} to \cw{true} if it or the backend does
something in response to the keypress. A front end can use this to
decide whether to pass the keypress on to anything else that might
want to do something in response to it.
The following additional values of \c{button} are permitted to be
passed to this function by the front end, but are never passed on to
the back end. They indicate front-end specific UI operations, such as