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}->Move(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;