Thanks Mark!

Will gave that a try.


On Thu, 2012-02-09 at 09:09 +0000, Mark Dootson wrote:
> Hi,
> 
> Looks like a potential bug in wxWidgets / GTK interaction.
> 
> It appears that showing and moving a dialog in GTK causes a few extra 
> things to happen - including repositioning the dialog with respect to 
> the parent window if necessary. (code it would seem checks for changed 
> parent position and dialog coordinates to see if some movement is 
> necessary, amongst other things).
> 
> I have pasted a 'workaround' below which should allow you to use 
> Wx::Dialog in this way. You must call 'Show' before 'Move' as 'Show' 
> will reposition the dialog with respect to the parent. You must call 
> 'Move' twice to ensure the internal code does not 'skip' the process by 
> assuming a move is not necessary.
> 
> I think folks don't hit this bug very often because conceptually a 
> Dialog isn't something you would keep hidden and re-show. In most usage 
> you would get the user info and destroy the object. You would only have 
> a non-modal dialog if you wanted to continue background processing 
> whilst asking some questions.
> 
> For other top level windows where you don't want or need Wx::Dialog 
> features, better to use a Wx::Frame as a base class.
> 
> Hope it helps.
> 
> Mark
> 
> 
> sub ButtonClicked
> {
> my( $self, $event ) = @_;
> 
> if($self->{dialog_state}==0){
>      $self->{dialog}->Show(1);
>       $self->{dialog}->MoveXY(99,99);
>       $self->{dialog}->MoveXY(100,100);
>       $self->{dialog_state}=1;
> }
> else{
>       $self->{dialog}->Show(0);
>       $self->{dialog_state}=0;
> }
> 
> }
> 
> 
> 
> On 08/02/2012 22:39, jeff wrote:
> > One slight correction. That code on ~line 50 should be Movexy(100,100) -
> > some folks might be use to seeing MoveXY, but both work and display the
> > same odd behavior.
> >
> >
> > -------- Forwarded Message --------
> >
> > Have some odd behavior here.
> > Here is a test simple script. It simple opens and closes a non modal
> > dialog by click a button on the main window.
> >
> > On the 1st click it will open the dialog at the requested location.
> > Click the button a 2nd time and it will close.
> > Click it a 3rd time and it will center on parent - hiding  the main
> > window.
> > Move it aside.
> > Click it a 4th time and it will close.
> > Click it a 5th time and it will open at the requested location.
> > And on and on., alternating between the two positions.
> >
> > The line of interest is ~ line 50.
> > Having this behavior in many locations in real code :-(
> >
> > Anyone have any ideas?   Hopefully we're just being stupid  ;-)
> >
> > Jeff
> >
> > ##################################### CUT HERE
> > #################################
> > use strict;
> > use Wx;
> > ###########################################################
> > #
> > # Extend the Frame class to our needs
> > #
> > package MyFrame;
> >
> > use Wx::Event qw( EVT_BUTTON );
> > use Wx qw/:everything/;
> >
> > use base qw/Wx::Frame/; # Inherit from Wx::Frame
> >
> > sub new
> > {
> > my $class = shift;
> >
> > my $self = $class->SUPER::new(@_);  # call the superclass' constructor
> >
> > # Then define a Panel to put the button on
> > my $panel = Wx::Panel->new( $self,  # parent
> > -1      # id
> > );
> >
> > my $BTNID = 1;  # store the id of the button in $BTNID
> >
> > $self->{btn} = Wx::Button->new(     $panel,             # parent
> > $BTNID,             # ButtonID
> > ">>>  Press me<<<", # label
> > [50,50]             # position
> > );
> >
> > EVT_BUTTON( $self,          # Object to bind to
> > $BTNID,         # ButtonID
> > \&ButtonClicked # Subroutine to execute
> > );
> >
> > $self->{dialog} = Wx::Dialog->new($self, -1, "test dialog");
> > $self->{dialog_state}=0;
> >
> > return $self;
> > }
> >
> > sub ButtonClicked
> > {
> > my( $self, $event ) = @_;
> >
> > if($self->{dialog_state}==0){
> >     $self->{dialog}->MoveXY
> >
> > (100, 100);
> >     $self->{dialog}->Show(1);
> >     $self->{dialog_state}=1;
> > }
> > else{
> >     $self->{dialog}->Show(0);
> >     $self->{dialog_state}=0;
> > }
> > }
> >
> > ###########################################################
> > #
> > # Define our ButtonApp2 class that extends Wx::App
> > #
> > package ButtonApp2;
> >
> > use base qw(Wx::App);   # Inherit from Wx::App
> >
> > sub OnInit
> > {
> > my $self = shift;
> > my $frame = MyFrame->new(   undef,         # Parent window
> > -1,            # Window id
> > 'Button interaction example', # Title
> > [300,400],         # position X, Y
> > [200, 150]     # size X, Y
> > );
> > $self->SetTopWindow($frame);    # Define the toplevel window
> > $frame->Show(1);                # Show the frame
> > }
> >
> > ###########################################################
> > #
> > # The main program
> > #
> > package main;
> >
> > my $wxobj = ButtonApp2->new(); # New ButtonApp application
> > $wxobj->MainLoop;
> >
> >
> >
> >
> > ______________________________________________________________________
> > This email has been scanned by the Symantec Email Security.cloud service.
> > For more information please visit http://www.symanteccloud.com
> > ______________________________________________________________________
> >
> >
> 
> 
> ______________________________________________________________________
> This email has been scanned by the Symantec Email Security.cloud service.
> For more information please visit http://www.symanteccloud.com
> ______________________________________________________________________


Reply via email to