Prev | Current Page 896 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

These events can then be handled in your code through the use of
function pointers.
The Button Control
The most simple of the interactive controls is the Button control. Here, you are provided with a simple
clickable object that can display either textual or graphical content. The Button control provides support
for the single solitary event, onClick , which is fired both when the button is pressed and when it is
released. When the event is triggered, the function assigned to the onClick event is called and passed an
integer value depicting the current state of the button; 1 for pressed and 0 for released. The following
example demonstrates this characteristic:
import nGui.Manager;
import nGui.controls.Label;
import nGui.controls.Button;
import nGui.controls.containers.VBox;
import nGui.controls.containers.Dialog;
class ButtonSampleCallback
Figure 17-2
Chapter 17: Desktop Applications with Neko
489
{
public static function main()
{
var bs = new ButtonSampleCallback();
}
public function new()
{
var mng = new Manager();
var vert : VBox = new VBox();
var lbl : Label = new Label( ???Click the button below??? );
var button1 : Button = new Button( ???Click Me??? );
vert.


Pages:
884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908