This helpfile is part of a GUI tutorial.
It is the first part of a beginner's introduction to SuperCollider's GUI system. Second part covers interfacing a synth with a GUI interface, while third part talks about composing views with basic GUI components.
To create a Window in SuperCollider, simply execute the following code:
The first command creates the window, and the second tells your graphical system to display it.
You can customize its name, position and size directly when creating it:
You can also toggle its fullscreen mode:
If you executed the previous example, you might have noticed that closing it can be difficult, because it doesn't show its top menu, and doesn't respond to keyboard inputs. To close every window that SuperCollider created using code, simply execute the following command:
If you stored your window in a global variable, you can also close it directly:
Once closed, you need to recreate it, because it has been completely deleted.
Every time you hit ctrl + shift + ., this will close the window you're currently creating, if it is still open, preventing the accumulation of windows during development process.
Once you've created the window, you can add a View directly into it, by passing the window as parent argument when creating the View:
When doing so, you are responsible for setting your View at the right position and size:
If you'd rather use automatic positioning and automatic resizing when the window is re-sized, you should use a Layout:
See Layout for more information about this organisation method. The layout system is also discussed in the next tutorial of this series.
Window 'inherits' from the UserView action system. It can respond to mouse and keyboard events. See the UserView help file for more information about this.
Another way to interact with the window using the keyboard, which might be preferable, is to assign a function to View.globalKeyDownAction
.
View.globalKeyDownAction
will be executed whenever a keyboard input is received (regardless of current focus), and allows an action to take place in response to the keyboard event, for example closing the window:
View.globalKeyDownAction
allows to incrementally build up keyboard input response:With the ability to create a window, insert views inside and make it respond to keyboard inputs, you're well set to go forward in your SuperCollider graphical experiments.
The next section of this tutorial is: GUI: Interfacing an instrument with a View. It starts from the previous examples and talks about connecting a button and a slider to a synth, and about the layout system.