From: <woo...@so...> - 2004-02-24 03:05:02
|
G'day, I'm writing an App which uses several buttons which do a similar thing: Select a job, one per button Which I do like this: foreach (@{$this->{jobs}}) { my $job_button = Wx::Button->new($jobs_panel,-1,$_); EVT_BUTTON($this,$job_button, \&OnJobClick); $job_box_sizer->Add($job_button,0,wxALL|wxALIGN_CENTRE|wxGROW,2); } Then I handle the event like this; sub OnJobClick { my ($this,$event) = @_; return unless $event; my $clicked_button = $event->GetEventObject; my $job = $clicked_button->GetLabel; $this->JobChange($job); } According to the docs (http://www.wxwindows.org/manuals/2.4.2/wx130.htm#wxevent), I can call GetEventObject, which should return the button, but no joy: Can't locate object method "GetEventObject" via package "Wx::CommandEvent" at backup.pl line 477. WinXP Wx-0.18 Perl 5.8.2 (ActiveState) What am I doing wrong? Cheers, Woody |
From: DH <cra...@ya...> - 2004-02-24 08:04:30
|
--- woo...@so... wrote: > G'day, > > I'm writing an App which uses several buttons which do a similar thing: > Select a job, one per button > > Which I do like this: > > > foreach (@{$this->{jobs}}) { > my $job_button = Wx::Button->new($jobs_panel,-1,$_); > EVT_BUTTON($this,$job_button, \&OnJobClick); > $job_box_sizer->Add($job_button,0,wxALL|wxALIGN_CENTRE|wxGROW,2); > } > > Then I handle the event like this; > > sub OnJobClick { > my ($this,$event) = @_; > return unless $event; > my $clicked_button = $event->GetEventObject; > my $job = $clicked_button->GetLabel; > $this->JobChange($job); > } > > According to the docs > (http://www.wxwindows.org/manuals/2.4.2/wx130.htm#wxevent), I can call > GetEventObject, which should return the button, but no joy: You're looking at the wrong docs. You need to get the annotated docs from http://wxperl.sf.net which say wxEvent::GetEventObject wxPerl note: This method is not implemented in wxPerl Try using $this->FindWindow( $event->GetId() )->GetLabel Hmm, I think I suggested once we just implement GetEventObject with ->FindWindow( $event->GetId() ) instead of wrapping it, should work __________________________________ Do you Yahoo!? Yahoo! Mail SpamGuard - Read only the mail you want. http://antispam.yahoo.com/tools |
From: Mattia B. <mat...@li...> - 2004-02-28 14:13:04
|
Il Mon, 23 Feb 2004 23:56:02 -0800 (PST) DH <cra...@ya...> ha scritto: > > According to the docs > > (http://www.wxwindows.org/manuals/2.4.2/wx130.htm#wxevent), I can > call > > GetEventObject, which should return the button, but no joy: > Try using > $this->FindWindow( $event->GetId() )->GetLabel Wrapped now. Use the above workaround until 0.19. Regards Mattia |
From: Scott L. <lan...@wh...> - 2004-02-29 19:41:53
|
On Sat, 28 Feb 2004, Mattia Barbon wrote: > Il Mon, 23 Feb 2004 23:56:02 -0800 (PST) DH <cra...@ya...> ha scritto: > > > According to the docs > > > (http://www.wxwindows.org/manuals/2.4.2/wx130.htm#wxevent), I can > > > call GetEventObject, which should return the button, but no joy: > > > > Try using > > $this->FindWindow( $event->GetId() )->GetLabel > > Wrapped now. Use the above workaround until 0.19. Sorry if I'm misunderstanding something, as I wasn't keeping tabs on this thread before, but does this mean GetEventObject is wrapped now? The reason I ask is I remembered this comment in Event.xs: # unimplemented ( and probably will never be: problems with object # cloning/destruction ) # GetEventObject # GetObjectType # SetEventObject I remembered it because I wanted to use GetEventObject one time and was disappointed it wasn't wrappable, and as a consequence you had to use some ugly thing where you saved the event object in the frame object rather than getting it from $self in the event callback. (Sorry if that made no sense.) |
From: DH <cra...@ya...> - 2004-03-01 05:33:45
|
--- Scott Lanning <lan...@wh...> wrote: > On Sat, 28 Feb 2004, Mattia Barbon wrote: > > Il Mon, 23 Feb 2004 23:56:02 -0800 (PST) DH <cra...@ya...> ha scritto: > > > > According to the docs > > > > (http://www.wxwindows.org/manuals/2.4.2/wx130.htm#wxevent), I can > > > > call GetEventObject, which should return the button, but no joy: > > > > > > Try using > > > $this->FindWindow( $event->GetId() )->GetLabel > >0 > > Wrapped now. Use the above workaround until 0.19. > > Sorry if I'm misunderstanding something, > as I wasn't keeping tabs on this thread before, > but does this mean GetEventObject is wrapped now? Yes, that's what it means (ain't English fun? :) __________________________________ Do you Yahoo!? Get better spam protection with Yahoo! Mail. http://antispam.yahoo.com/tools |
From: Mattia B. <mat...@li...> - 2004-03-01 21:35:26
|
Il Sun, 29 Feb 2004 20:29:00 +0100 (CET) Scott Lanning <lan...@wh...> ha scritto: > On Sat, 28 Feb 2004, Mattia Barbon wrote: > > Il Mon, 23 Feb 2004 23:56:02 -0800 (PST) DH > <cra...@ya...> ha scritto: > > > > According to the docs > > > > (http://www.wxwindows.org/manuals/2.4.2/wx130.htm#wxevent), I > can > > > > call GetEventObject, which should return the button, but no > joy: > > > > > > Try using > > > $this->FindWindow( $event->GetId() )->GetLabel > > > > Wrapped now. Use the above workaround until 0.19. > > Sorry if I'm misunderstanding something, > as I wasn't keeping tabs on this thread before, > but does this mean GetEventObject is wrapped now? Yes. > The reason I ask is I remembered this comment > in Event.xs: > > # unimplemented ( and probably will never be: problems with object > # cloning/destruction ) > # GetEventObject > # GetObjectType > # SetEventObject > > I remembered it because I wanted to use GetEventObject > one time and was disappointed it wasn't wrappable, > and as a consequence you had to use some ugly thing > where you saved the event object in the frame object > rather than getting it from $self in the event callback. > (Sorry if that made no sense.) It makes sense. The reason it now is implemented is that it only works if the object is a wxWindow or derived class, which coverts 99.9% of real world uses. Regards Mattia |