Bonjour,

Je cherche à insérer un menu "pop-up" via un clic droit dans une MlistBox. Voici la partie de mon code :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
my $btlist = $frame4->Scrolled ('MListbox',-columns => [
  [ -text =>'Category', -sortable => 1],
  [ -width => 90,-text =>'File', -sortable => 1],
  [ -text =>'Category2', -sortable => 1,-comparecommand => sub { $_[0] <=> $_[1]}],
  [ -text =>'Category3', -sortable => 1,-comparecommand => sub { $_[0] <=> $_[1]}],
  [ -text =>'Category4', -sortable => 1,-comparecommand => sub { $_[0] <=> $_[1]}]],
  -moveable =>0,-background => $maincolor,-font => $mainfont,-scrollbars => 'osoe',-selectmode =>  'extended', -height => 10,-width => 450,
)->pack(-side => 'top', -fill => 'both');
 
#######Right clic menu###########
my $menu = $btlist ->Menu(
  -tearoff    => 0,
  -takefocus  => 1,
  -background => "white",
  -menuitems  => [
    [ 'command', => 'un',   -command => [ \&affichage, 'un' ] ],
    [ 'command', => 'deux', -command => [ \&affichage, 'deux' ] ],
    '-',    # séparateur
    [ 'command', => 'trois',  -command => [ \&affichage, 'trois' ] ],
    [ 'command', => 'quatre', -command => [ \&affichage, 'quatre' ] ],
  ],
);
 
$btlist ->Tk::bind( '<ButtonPress-3>', sub { $menu->Popup( -popover => 'cursor', -popanchor => 'nw' ); print "MENU\n";} );
#######End right clic menu###########
Je n'ai pas d'erreur au lancement, mais le menu ne s'ouvre pas après un clic droit. Pourtant quand je lie le menu à un bouton de la même fenêtre, cela fonctionne.

Quelqu'un aurait une idée d'ou peut venir l'erreur?