Paarvai Naai
2008-12-05 19:18:01 UTC
Hi,
I noticed something very strange with when hooking the wxEVT_SIZE
event in one of my custom controls. Specifically, for every discrete
window resize, I find that the wxEVT_SIZE seems to be issued 4(!)
times, thereby calling my event handler 4 times. This seems very
inefficient. In an effort to simplify things, I decided to test the
wxEVT_SIZE event on a simple wxApp.
I created a wxApp that instantiates a wxFrame which in turn creates a
wxPanel. The wxEVT_SIZE event is hooked as follows:
panel->Connect(ID_PANEL, wxEVT_SIZE,
wxSizeEventHandler(SizeTestFrame::OnSize), NULL, this);
The OnSize function is written as:
void SizeTestFrame::OnSize( wxSizeEvent& event )
{
static int count = 0;
printf("OnSize: %p %d\n", event.GetEventObject(), count++);
//event.Skip();
}
Now when I launch the app, I get 3 OnSize calls upon the initial
showing of the main frame. All show the same value from
event.GetEventObject() (presumably the panel's pointer). I am using
wxGTK 2.8.9. To resize the window, I right click on the titlebar and
select the resize option. This way I can use discrete events on my
keyboard to resize the window. Each resize results in 3 more calls to
OnSize.
Is this is a known issue? Is there some way I can squelch these extra
wxEVT_SIZE events?
Thanks,
Paarvai
I noticed something very strange with when hooking the wxEVT_SIZE
event in one of my custom controls. Specifically, for every discrete
window resize, I find that the wxEVT_SIZE seems to be issued 4(!)
times, thereby calling my event handler 4 times. This seems very
inefficient. In an effort to simplify things, I decided to test the
wxEVT_SIZE event on a simple wxApp.
I created a wxApp that instantiates a wxFrame which in turn creates a
wxPanel. The wxEVT_SIZE event is hooked as follows:
panel->Connect(ID_PANEL, wxEVT_SIZE,
wxSizeEventHandler(SizeTestFrame::OnSize), NULL, this);
The OnSize function is written as:
void SizeTestFrame::OnSize( wxSizeEvent& event )
{
static int count = 0;
printf("OnSize: %p %d\n", event.GetEventObject(), count++);
//event.Skip();
}
Now when I launch the app, I get 3 OnSize calls upon the initial
showing of the main frame. All show the same value from
event.GetEventObject() (presumably the panel's pointer). I am using
wxGTK 2.8.9. To resize the window, I right click on the titlebar and
select the resize option. This way I can use discrete events on my
keyboard to resize the window. Each resize results in 3 more calls to
OnSize.
Is this is a known issue? Is there some way I can squelch these extra
wxEVT_SIZE events?
Thanks,
Paarvai