How to implement timeout behavior for wxTextCtrl 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 implement timeout behavior for wxTextCtrl

Post by denarced »

Hello,

do you have any ideas on how to implement automatic database search when the user stops typing for, let's say, 500ms?
I thought about it and all I could come up with was having a separate thread for the timer.
If that's the best solution, is there some utilities in wxWidgets that'll make the implementation easy?
Usually I tend to avoid writing threading code myself ..
JimFairway
wxWorld Domination!
wxWorld Domination!
Posts: 1059
Joined: Sun Dec 30, 2007 6:40 pm
Location: Canada

Re: How to implement timeout behavior for wxTextCtrl

Post by JimFairway »

Hi,

How about catch the wxEVT_COMMAND_TEXT_UPDATED event for the wxTextCtrl (see EVT_TEXT) and start a timer using wxTimer, set the timer for OneShot mode.
When the timer fires, process the entry.

Hope that helps,

Jim
OS: Vista SP1, wxWidgets 2.8.7.
denarced
Knows some wx things
Knows some wx things
Posts: 47
Joined: Sun Dec 04, 2011 7:25 am

Re: using wxTimer in OneShot mode

Post by denarced »

JimFairway, your suggestion was pretty perfect.
I'll have to remember that the next time when I'm implementing something like this.
Thanks!

I did however implement one solution which is based on threads.
And it works so I'm too lazy to change it now :)
Post Reply