|< 1 2 >| | 11 Einträge, 2 Seiten |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use Tk;
use Tk::PopupButton;
my $mw = new MainWindow;
my $menu = [[ 'command' => 'Funktion1',
-command => sub { print "Funktion1\n"; }],
[ 'command' => 'Funktion2',
-command => sub { print "Funktion2\n"; }]];
$mw->PopupButton(-text => 'weitere Funktionen...',
-menu => $menu
)->pack();
MainLoop();
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
package Tk::PopupButton;
use Tk::Frame;
use Tk::Button;
@ISA = qw/Tk::Frame/;
Construct Tk::Widget 'PopupButton';
sub Populate {
my($w, $args) = @_;
my $menu = delete $args->{-menu};
my $m = $w->Menu(-tearoff => 0,
-menuitems => $menu);
$w->SUPER::Populate($args);
my $b = $w->Button(-relief => 'groove')->pack(-side => 'left');
my $ba = $w->Button(-image => $w->Bitmap(-file => 'e:/perl/site/lib/Tk/cbxarrow.xbm'))->pack(-side => 'left', -fill => 'y');
$ba->bind('<ButtonPress-1>' => [\&popup, $m]);
$w->ConfigSpecs(DEFAULT => [$b]);
}
sub popup {
my($w, $m) = @_;
$m->Popup(-popover => "cursor",
-popanchor => 's');
}
1;
Tk->findINC("cbxarrow.xbm")
|< 1 2 >| | 11 Einträge, 2 Seiten |