File: mouse_focustest

package info (click to toggle)
libcurses-ui-perl 0.9609-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,312 kB
  • sloc: perl: 12,464; makefile: 2
file content (60 lines) | stat: -rwxr-xr-x 1,112 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/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,
			  -mouse_support => 1);

my $sw = $cui->add(
    undef, 'Window',
    -y => -1,
    -height => 3,
    -width => -1,
    -border => 1,
);
my $status = $sw->add(
    undef, 'Label',
    -width => -1,
    -padright => 8,
    -text => 'Status: program started... Use the mouse to shift focus'
);
$sw->add(
    undef, 'Buttonbox',
    -buttons => [{
        -label=>'< Quit >',
	-onpress => sub {exit(0)},
    }],
    -width => 8,
    -buttonalignment => 'right',
    -x => -1,
);


for my $nr (1..5)
{
    $cui->add(
	undef, 'Window',
	-x => 12*$nr - 9,
	-y => 2*$nr - 1,
	-width => 20, 
	-height => 10,
	-border => 1,
	-title => "window $nr",
	-onfocus => sub{
	    $status->text("Status: Focus to window $nr"); 
	},
    );
}

$cui->set_binding(sub{exit}, "\cC", "\cQ");

if ($Curses::UI::ncurses_mouse) {
    $status->text($status->text() . " (mouse support enabled)"); 
} else {
    $status->text($status->text() . " (mouse support disabled)"); 
}

$cui->mainloop;