![]() |
Gorgon Game Engine
|
This example shows how to create a simple button.
Create the following templates:
These two templates will create a very simple button that has the background and it will display the text that is set by the programmer. If you wish to change the color of the text when the user moves mouse into the button, add the following template as well:
This component will override the previous if the mouse is over the button. In order to change the background when the user clicks the button, add the following:
This will change the background when the user presses the mouse button. Both hover and down conditions can occur at the same time. If user uses mouse to press the button they will both be active at the same time, however, if the user uses space bar to press the button when it is focused, only Down condition will be satisfied. In addition to these, it is helpful to provide a visual clue when the widget is focused. This is generally done by adding a focus rectangle like the following:
This last piece will only be shown when the button is focused. There will be no errors when it is invisible even when the container lists this template as its child.