Wednesday 23 of April 2008 14:22:37 Daniel napisaƂ(a):
> Hi all,
> 
> I have a wx::TreeCtrl an when the user right-clicks I want to do something 
> with the childitems.
> 
> At first I tried this:
> 
>      EVT_TREE_ITEM_RIGHT_CLICK($panel, $panel->{TreeCtrl}{"status"}, sub {
>            my $selected = $panel->{TreeCtrl}{"status"} -> GetSelection();
>            my $parent = $panel->{TreeCtrl}{"status"} -> 
> GetItemText($selected);
>            F_MyMessage($self,"Status: 
> $parent","Hinweis",wxOK|wxCENTRE|wxICON_INFORMATION);
>      });
> 
> But as expected I get only the information of the selected item, not the one 
> I clicked.
> 
> So i used GetItem from TreeEvent instead of GetSelection :
> wxTreeEvent::GetItemwxTreeItemId GetItem() const
> Returns the item (valid for all events).
> 
>            my $selected = $panel->{TreeCtrl}{"status"} -> GetItem();
> 
> 
> --> Can't locate object method "GetItem" via package "Wx::TreeCtrl" at...
> 
> What am I doing wrong?

Try this:

$this is a TreeCtrl object; for instance:

###########################
package myTree;

use Wx;
use vars qw(@ISA);
@ISA = qw(Wx::TreeCtrl);

sub new {
        my $class = shift;
        my $this = $class->SUPER::new( @_ );
#...
        my $root = $this->AddRoot( 'foo', 1,1, Wx::TreeItemData->new( 'bar' ) );
#...
        use Wx::Event qw( EVT_TREE_ITEM_RIGHT_CLICK );
        EVT_TREE_ITEM_RIGHT_CLICK ( $this, $this, \&rightclick );
}

sub rightclick {
        my ( $this, $event ) = @_;
        my $item = $event->GetItem;

        Wx::LogMessage( 'Prawy klik: %s', $this->GetPlData( $item ) );
}
####################################

wb


> 
> 
> Regards Daniel
> 
> 
> 
> 
> 
> 
> 
> 
> 
>       __________________________________________________________
> Gesendet von Yahoo! Mail.
> Der Mailbox mit unbegrenztem Speicher.
> http://de.overview.mail.yahoo.com
> 


Reply via email to