From: <Smi...@sy...> - 2006-06-07 18:55:16
|
Hi All;=20 I have a popup menu like this: $self->{rclick_menu} =3D Wx::Menu->new( ); my ($ID_BREAK_UP_SHEET, $ID_RECOMBINE_SHEET, $ID_ASSIGN_FILE)=3D(201..300); $self->{rclick_menu}->Append( $ID_BREAK_UP_SHEET, "Break Up Sheet", "" ); $self->{rclick_menu}->Append( $ID_RECOMBINE_SHEET, "Recombine Sheet", "" ); $self->{rclick_menu}->Append( $ID_ASSIGN_FILE, "Assign Program", "" ); I'd like to use it on several buttons, and have the sub I call from EVT_BUTTON know what button the right click menu was over, so when I define my buttons: foreach $button (@buttons_I_want_to_make) { $self->{$button} =3D Wx::BitmapButton->new( $self->{panel1}, .... ); EVT_MENU( $self{rclick_menu}, $ID_BREAK_UP_SHEET, sub { breakSheet($button, @_) } ); EVT_MENU( $self{rclick_menu}, $ID_RECOMBINE_SHEET, sub { mergeSheet($button, @_) } ); EVT_MENU( $self{rclick_menu}, $ID_ASSIGN_FILE, sub { openProg($button, @_) } ); EVT_RIGHT_UP( $self->{$button}, sub {=20 my ($self, $event) =3D @_; $self{rclick_menu}->SetTitle("Sheet $sheet"); my $tmp_pnt =3D Wx::Point->new($event->GetX, $event->GetY); $self->PopupMenu( $self{rclick_menu}, $tmp_pnt ); } ); } I get the popup menu in the location I want and can conditionally set the title of the menu so that it could maybe somehow be picked up by the sub's breakSheet, mergeSheet, openProg, but the only way I can think of is to subclass Menu and add custom data functions or maybe use class global variables that will get modified by EVT_RIGHT_UP's subroutine. Can someone point me in a BETTER direction? I think I can get this to work but it just seems ugly to me. Thanks, Nate Smith =20 |