Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I'm confused on how to determine the actual x,y screen coordinates for a popup menu. I'm able to locate the x,y coordinates based on my ListCtrl widget but unfortunately my popup menu is being placed based on x,y coordinates from the upper left hand corner of my main app.

Here is my code snippet

sub CreateUserPopupMenu { my( $self, $event ) = @_; my $x=$event->GetPoint()->x; my $y=$event->GetPoint()->y; print "X: $x\n"; print "Y: $y\n\n"; my $menu=Wx::Menu->new(); $menu->Append($id[1000], "Delete User"); EVT_MENU( $self, $id[1000], \&DeleteUser ); $self->PopupMenu($menu, $x, $y); }
I'm able to get the current width and height of my main app via
my $sz = $self->GetSize(); my ($posx,$posy) = $self->ClientToScreen((0,0)); my $height = $sz->GetHeight(); my $width = $sz->GetWidth();
Am I missing the obvious or is there a better way to determine the actual x,y coordinate of my mouse click based on the current screen resolution?

Replies are listed 'Best First'.
Re: WxPerl x,y coordinates
by Anonymous Monk on Nov 15, 2008 at 02:03 UTC