#!/usr/bin/perl -w
use strict;

use FindBin;
use lib "$FindBin::RealBin/../lib";
use Curses::UI;
my $cui = new Curses::UI ( -clear_on_exit => 1 );

my $win = $cui->add('window_id', 'Window');

$win->add(
        'label1', 'Label',
        -text => "Press <CTRL+Q> to leave this demo."
);

my $cb = $win->add(
        'mycheckbox', 'Checkbox',
	-y => 3,
        -label     => "Say hello to the world",
	-onchange   => sub {
		my $cb = shift;
		my $this = $cb->parent;
		my $cb2 = $this->getobj('mycheckbox2');
		$cb->get ? $cb2->check : $cb2->uncheck;
	},
);

$win->add(
        'mycheckbox2', 'Checkbox',
	-y => 5,
        -label     => "This one is automatically set if the\n"
		    . "checkbox above is changed using an\n"
		    . "onChange event...",
);


$win->returnkeys("\cQ");
$win->focus;

if ($cb->get) {
	$cui->dialog("Hello, world!");
}

