How to call method immediately when GUI is visible? Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
denarced
Knows some wx things
Knows some wx things
Posts: 47
Joined: Sun Dec 04, 2011 7:25 am

How to call method immediately when GUI is visible?

Post by denarced » Thu Jul 05, 2012 10:55 am

Hello,

I have a refresh button in my GUI, and in all use cases the first thing the user does is push that button. I'm now trying to automatically do it. But refreshing takes a couple of seconds. During that time many users will go to start menu and click again. How can I show the GUI and then immediately "push" the button?

Thank you

User avatar
doublemax
Moderator
Moderator
Posts: 15159
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: How to call method immediately when GUI is visible?

Post by doublemax » Thu Jul 05, 2012 12:59 pm

There is no easy/elegant way to do this. You can try catching the first idle event or use a one-shot timer.
http://docs.wxwidgets.org/trunk/classwx_idle_event.html
Use the source, Luke!

denarced
Knows some wx things
Knows some wx things
Posts: 47
Joined: Sun Dec 04, 2011 7:25 am

Re: How to call method immediately when GUI is visible?

Post by denarced » Fri Jul 06, 2012 4:27 am

doublemax wrote:There is no easy/elegant way to do this. You can try catching the first idle event or use a one-shot timer.
http://docs.wxwidgets.org/trunk/classwx_idle_event.html
Thanks! Even if not elegant, it's something. Before I had nothing. That's an infinite improvement :)

denarced
Knows some wx things
Knows some wx things
Posts: 47
Joined: Sun Dec 04, 2011 7:25 am

Solution

Post by denarced » Fri Jul 06, 2012 11:10 am

The solution I ended up using is very simple:
Register the idle event.
Catch the first and do what must be done.
Ignore the rest (could've also unbind).

Works like a charm.
I don't think it's "elegant" but it's close enough.

Post Reply