Alexandr Ciornii <[email protected]> writes:
> 2012/12/9 Johan Vromans <[email protected]>:
>> Alexandr Ciornii <[email protected]> writes:
>>
>>> I'm writing a program that uses Wx::TreeListCtrl. I want to show
>>> context menu on right click. But event has coordinates (0,0), so
>>> context menu is shown in the incorrect place.
>>
>> Have you tried:
>>
>> my $point = $event->GetPoint;
>> $self->PopupMenu( $menu, $point );
>
> Yes, with same result. $point is {x=>0, y=>0}.
Strange. I have code that does that (although I use GetPosition instead
of GetPoint. However, that should not make a difference...
Code (simplified):
sub OnRightClick {
my ($self, $event) = @_;
my ($item, $flags) = $self->HitTest($event->GetPosition);
return if $flags & wxTREE_HITTEST_NOWHERE;
$self->SelectItem($item);
my $data = $self->GetPlData($item);
$data->ctxmenu( $event, $self, $item );
}
sub ctxmenu {
my ($self, $event, $ctl, $item) = @_; # (this instance, click event, tree
ctrl, tree item)
my $ctxmenu = Wx::Menu->new("");
$ctxmenu->Append(CTXMENU_OPEN, "Details");
...
$ctl->PopupMenu($ctxmenu, $event->GetPosition);
}
-- Johan