-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
OpenFrameworks Essentials
By :
The keyboard events are handled by the keyPressed(int key) and keyReleased(int key) functions, which are called by openFrameworks when a key is pressed and released respectively. The key input argument holds the numerical code of the key. Let's implement handling key pressings in our project and use it to add some desirable features: hiding GUI, saving screenshots, and saving/loading presets.
We consider here only key pressing events. Handling key releasing is implemented in a similar way.
In order to capture the image generated with our project, we need to be able to hide the GUI from the screen. To achieve this, let's define the Boolean variable showGui, implement its toggling by pressing Z, and use its value to decide whether we should draw gui on the screen:
ofApp class:bool showGui;
setup():showGui = true;
Change the font size
Change margin width
Change background colour