Hi,

Command Events are propagated to parent windows. EVT_LEFT_DOWN is not a Command Event.

I have come across the issue of different mouse event behaviour across operating systems before.

Assuming that what you want to catch in the panel is any user interaction at all, I think pushing an event handler on to the child widgets would represent the least changes to your code.

Example below.
Lifted from working code - there my be typo's though.

Hope this helps


#------ in panel constructor

use My::EvtHandler;
...
...

my $widget = Wx::StaticBitmap->new($panel, -1, ... );
My::EvtHandler->new($widget);

my $widget2 = Wx::TextCtrl->new($panel, -1, ... );
My::EvtHandler->new($widget2);

...

EVT_COMMAND($panel, -1, $My::EvtHandler::TRACK_MOUSE_EVENT, \&mysub);


#----------

package My::EvtHandler;

use strict;
use warnings
use Wx;
use Wx::Event qw( EVT_LEFT_DOWN );
use base qw (Wx::EvtHandler);

our $TRACK_MOUSE_EVENT = Wx::NewEventType;

sub new {
  my ($class, $window) = @_;
  my $handler = $class->SUPER::new;
  $window->PushEventHandler( $handler );

  EVT_LEFT_DOWN($window,sub { $handler->OnMouseLD( $window, $_[1] ); });

  return $handler;
}

sub OnMouseLD {
  my($handler, $window, $event) = @_;
  $event->Skip(1);
  my $id = $window->GetId;
  my $newevent = Wx::CommandEvent->new($TRACK_MOUSE_EVENT, $id);
  $window->ProcessEvent($newevent);
}

1;



On 08/02/2011 09:20, Johan Vromans wrote:
Hi,

I have an application that displays a panel, and the panel contains a
widget (bitmap). It's a touchscreen application, so the whole
panel is sensitive to being clicked (touched).

Apparently command events are not propagated from a widget to its
parent, so I force propagation explicitly. This is an excerpt from the
code:

   my $widget = Wx::StaticBitmap->new($panel, -1, ... );

   Wx::Event::EVT_LEFT_UP( $widget, sub {
        $_[1]->ResumePropagation(1);
        $_[1]->Skip;
   } );

   Wx::Event::EVT_LEFT_UP( $panel, \&action );

This works w/o problems.

Now I've added EVT_LEFT_DOWN in the same manner:

   Wx::Event::EVT_LEFT_DOWN( $widget, sub {
        $_[1]->ResumePropagation(1);
        $_[1]->Skip;
   } );

   Wx::Event::EVT_LEFT_DOWN( $panel, \&someotheraction );

This works on Linux, but I don't seem to get EVT_DOWN on Windows.

Before investigating this further, does this look familiar to anybody?

-- Johan

  • MouseDown Johan Vromans
    • Re: MouseDown Mark Dootson

Reply via email to