From: DH <cra...@ya...> - 2005-02-15 01:43:58
|
--- Nick Johnston <sk...@er...> wrote: > DH wrote: > > >--- "sk...@er..." <sk...@er...> wrote: > > > >>riginal Message: > >>----------------- > >>From: DH cra...@ya... > >>Date: Sun, 13 Feb 2005 20:47:05 -0800 (PST) > >>To: sk...@er..., wxp...@li... > >>Subject: Re: [wxperl-users] ListBox in Notebook doesn't accept mouse input > >> > >> > >> > >>>Because I am psychic, I know you're listening for some kind of mouse event, > >>>and you're not Skip-ing. You need to Skip > >>> > >>> > >>Thanks for the reply. I am not explicitly listening for a mouse event. Does > >>the Notebook have an implicit mouse event which I need to skip or delegate > >>to the list box? > >> > >>Do I just have to use an event handler which gets the Wx::Event object and > >>calls Skip on it? > >> > >> > > > >No and no. > >What you need to do is submit a minimal code snippet which demonstrates > >the undesired behaviour. > > > >Despite my psychic ability, > >I can't envision any other scenario other than the one I described, > >but in either case you should've tendered code rather than a description. > > > > > I'm assuming the code I submitted in my first message was insufficient, > so here is a self-contained wxPerl app which demonstrates the problem. > > package TestFrame; > > use strict; > use Wx qw(:everything); > use base 'Wx::Frame'; > use Wx::Event qw(EVT_MENU EVT_BUTTON EVT_LIST_ITEM_ACTIVATED > EVT_RADIOBUTTON); > > sub new { > my $class = shift; > my $self = $class->SUPER::new(@_); > > # Create a panel for the whole window or frame > $self->{panel} = Wx::Panel->new($self, -1, [0, 0], $self->GetSize()); > > my ($width, $height) = $self->GetSizeWH(); > > # Create a 'notebook' (i.e. a set of tabs) > $self->{notebook} = Wx::Notebook->new($self->{panel}, -1, [0, 0], > [$width, $height - 70]); > > # Create a panel for active/unsent invoices > $self->{panel_unsent} = Wx::Panel->new($self, -1); > > # Create a panel for sent/archived invoices > $self->{panel_sent} = Wx::Panel->new($self, -1); > > # So they are visible, add these panels to the notebook > $self->{notebook}->AddPage($self->{panel_unsent}, > "Unsent/active invoices"); > $self->{notebook}->AddPage($self->{panel_sent}, > "Sent/archived invoices"); > > # Create an OK button that will be displayed below the notebook/tabs. > $self->{button_ok} = Wx::Button->new($self->{panel}, -1, "OK", > [ ($width - 60) / 2, $height - 60 ]); > > # Add items to the unsent/active tab > $self->{list_active} = Wx::ListBox->new($self->{panel_unsent}, > -1, [5, 5], [200, 370], [1, 2, 3], wxLB_ALWAYS_SB | wxLB_SORT); > > #$self->{list_active}->Append($_) for (1 .. 100); > > EVT_BUTTON($self, $self->{button_ok}, sub { $self->Close(1) }); > > $self->SetIcon(Wx::Icon->new('icircle.ico', wxBITMAP_TYPE_ICO)); > > return $self; > } > > > package TestApp; > > use strict; > use base 'Wx::App'; > use Wx qw(:everything); > > # We must provide an "OnInit" function that specifies what frames > # our application will use. > sub OnInit { > my $self = shift; > my $mainFrame = TestFrame->new( > undef, # Parent window > -1, # Window ID > 'Foo', # Window title > [5, 5], # X, Y position > [600, 480] # X, Y size > ); > > $self->SetTopWindow($mainFrame); # Set the top-level window. > $mainFrame->Show(1); # Show the frame. > } > > package main; > > TestApp->new()->MainLoop; > > > > > > Thanks, > > Nick Hmm, interesting. Its looking very much like a bug :( Here's an example that works, hopefully you can compare and figure out what the critical difference is between them (i'm not up to it at the moment) #!/usr/bin/perl -w -- # generated by wxGlade 0.4cvs on Sun Feb 13 20:35:55 2005 # To get wxPerl visit http://wxPerl.sourceforge.net/ use Wx 0.15 qw[:allclasses]; use strict; package MyFrame; use Wx qw[:everything]; use base qw(Wx::Frame); use strict; sub new { my( $self, $parent, $id, $title, $pos, $size, $style, $name ) = @_; $parent = undef unless defined $parent; $id = -1 unless defined $id; $title = "" unless defined $title; $pos = wxDefaultPosition unless defined $pos; $size = wxDefaultSize unless defined $size; $name = "" unless defined $name; # begin wxGlade: MyFrame::new $style = wxDEFAULT_FRAME_STYLE unless defined $style; $self = $self->SUPER::new( $parent, $id, $title, $pos, $size, $style, $name ); $self->{notebook_1} = Wx::Notebook->new($self, -1, wxDefaultPosition, wxDefaultSize, 0); $self->{notebook_1_pane_1} = Wx::Panel->new($self->{notebook_1}, -1, wxDefaultPosition, wxDefaultSize, ); $self->{list_box_1} = Wx::ListBox->new($self->{notebook_1_pane_1}, -1, wxDefaultPosition, wxDefaultSize, ["a", "b", "c"], ); $self->__set_properties(); $self->__do_layout(); # end wxGlade return $self; } sub __set_properties { my $self = shift; # begin wxGlade: MyFrame::__set_properties $self->SetTitle("frame_1"); $self->{list_box_1}->SetSelection(0); # end wxGlade } sub __do_layout { my $self = shift; # begin wxGlade: MyFrame::__do_layout $self->{sizer_1} = Wx::BoxSizer->new(wxVERTICAL); $self->{sizer_2} = Wx::BoxSizer->new(wxHORIZONTAL); $self->{sizer_2}->Add($self->{list_box_1}, 0, wxEXPAND|wxADJUST_MINSIZE, 0); $self->{notebook_1_pane_1}->SetAutoLayout(1); $self->{notebook_1_pane_1}->SetSizer($self->{sizer_2}); $self->{sizer_2}->Fit($self->{notebook_1_pane_1}); $self->{sizer_2}->SetSizeHints($self->{notebook_1_pane_1}); $self->{notebook_1}->AddPage($self->{notebook_1_pane_1}, "tab1"); $self->{sizer_1}->Add(Wx::NotebookSizer->new($self->{notebook_1}), 1, wxEXPAND, 0); $self->SetAutoLayout(1); $self->SetSizer($self->{sizer_1}); $self->{sizer_1}->Fit($self); $self->{sizer_1}->SetSizeHints($self); $self->Layout(); # end wxGlade } # end of class MyFrame 1; package MyApp; use base qw(Wx::App); use strict; sub OnInit { my( $self ) = shift; Wx::InitAllImageHandlers(); my $frame_1 = MyFrame->new(); $self->SetTopWindow($frame_1); $frame_1->Show(1); # use Wx::Event qw[ EVT_MOUSE_EVENTS ]; EVT_MOUSE_EVENTS( $frame_1->{list_box_1}, sub {warn "@_";$_[1]->Skip}); return 1; } # end of class MyApp package main; unless(caller){ my $app = MyApp->new(); $app->MainLoop(); } __________________________________ Do you Yahoo!? Yahoo! Mail - Easier than ever with enhanced search. Learn more. http://info.mail.yahoo.com/mail_250 |