Leser: 2
![]() |
|< 1 2 >| | ![]() |
15 Einträge, 2 Seiten |
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
61
62
63
64
65
66
67
68
#!/usr/bin/perl
use strict;
use warnings 'all';
use Tk;
use Tk::Balloon;
# MainWindow erstellen
my $mw = tkinit(-title => "Tk::Balloon");
# menuframe und statusframe erstellen
my $mf = $mw -> Frame ( -relief => "flat" ,
-bd => 1 )
-> pack ( -fill => "x" ,
-expand => 1 );
my $sf = $mw -> Frame ( -relief => "groove" ,
-bd => 1 )
-> pack ( -fill => "x" ,
-expand => 1 );
# Menü erstellen
my $menubar = $mf -> Menu ( -type => "menubar" ,
-menuitems =>
[
[
"cascade" => "Datei" ,
-tearoff => 0 ,
-menuitems =>
[
[
"command" => "Neu" ,
-command => sub { print"neu\n" }
] ,
"-" ,
[
"command" => "Beenden" ,
-command => sub { $mw->destroy }
]
]
]
] );
$mw -> configure ( -menu => $menubar );
# Statuslabel erstellen
my $sl = $sf -> Label ( -text => "Starttext" ,
-font => "{Arial} 10 {normal}" )
-> pack ( -side => "left" ,
-padx => 2 ,
-pady => 2 );
# Balloon erstellen
my $b = $mw -> Balloon ( -statusbar => $sl ,
-initwait => 1 ,
-state => "status" );
$b -> attach ( $sf ,
-msg => "Statusbar" );
# attach() menu entrys
$b -> attach ( $menubar ,
-state => "status" ,
-msg =>
[
"Menü: Datei" ,
"Eine neue Datei erstellen" ,
"Programm beenden"
] );
MainLoop;
$menubar->entrycget("Datei", -menu)
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
--- Tixish/Balloon.pm (revision 1452)
+++ Tixish/Balloon.pm (revision 1456)
@@ -169,6 +169,13 @@ sub Motion {
my $client = $over;
while (defined $client) {
last if (exists $w->{'clients'}{$client});
+ if ($client->can("MasterMenu")) {
+ my $master = $client->MasterMenu;
+ if ($master && exists $w->{'clients'}{$master}) {
+ $w->{'clients'}{$client} = $w->{'clients'}{$master};
+ last;
+ }
+ }
$client = $client->Parent;
}
if (defined $client) {
--- Tk/Menu.pm (revision 1452)
+++ Tk/Menu.pm (revision 1456)
@@ -1152,6 +1152,25 @@ sub BalloonInfo
}
}
+sub MasterMenu
+{
+ my ($menu) = @_;
+ my $pathname = $menu->PathName;
+ my $master_menu;
+ if ($pathname =~ m{#})
+ {
+ my $master_pathname = (split m{\.}, $pathname)[-1];
+ $master_pathname =~ s{#}{.}g;
+ $master_menu = $menu->Widget($master_pathname);
+ if (!Tk::Exists($master_menu))
+ {
+ warn "Cannot find master menu <$master_pathname>";
+ }
+ }
+ $master_menu;
+}
+
+
# ::tk::AmpMenuArgs --
# Processes arguments for a menu entry, turning -label option into
# -label and -underline options, returned by ::tk::UnderlineAmpersand.
![]() |
|< 1 2 >| | ![]() |
15 Einträge, 2 Seiten |