SetFocus

Jonathan Stoneman wrote:

Hi,

I have a frame that on creation sets up, among other things, a
wxTextCtrl and then calls the wxTextCtrl's SetFocus method. This does
not seem to be working when run in Windows, but works as I'd expect
under Linux. I can get round it by creating the wxTextCtrl before any
other controls, but would like to know why it is not working under
Windows. Could anyone enlighten me please?

With thanks,

Jon.

Focus can be a tricky thing, particularly since what gets the focus
can depend on actions taken after the point at which you're calling
SetFocus. Werner Bruhin recently had a similar issue with a list
control, and the usual answer (that Robin gave) is to try
the wxCallAfter() trick. This function, added by Robin to wxPython
a long time ago, allows you to say "call this function after all
of the currently queued events have been processed thoroughly,"
and in my experience usually solves such problems.

/Will Sadkin
Parlance Corporation
www.nameconnector.com

Worked like a charm. Thank you very much...

Jon.

ยทยทยท

On Thu, 2003-09-04 at 16:22, Will Sadkin wrote:

Jonathan Stoneman wrote:
> Hi,
>
> I have a frame that on creation sets up, among other things, a
> wxTextCtrl and then calls the wxTextCtrl's SetFocus method. This does
> not seem to be working when run in Windows, but works as I'd expect
> under Linux. I can get round it by creating the wxTextCtrl before any
> other controls, but would like to know why it is not working under
> Windows. Could anyone enlighten me please?
>
> With thanks,
>
> Jon.

Focus can be a tricky thing, particularly since what gets the focus
can depend on actions taken after the point at which you're calling
SetFocus. Werner Bruhin recently had a similar issue with a list
control, and the usual answer (that Robin gave) is to try
the wxCallAfter() trick. This function, added by Robin to wxPython
a long time ago, allows you to say "call this function after all
of the currently queued events have been processed thoroughly,"
and in my experience usually solves such problems.

--
Jonathan Stoneman - Programmer - Frontier Internet Services Limited
Tel: 02920 820000 Fax: 02920 820038 http://www.frontier.net.uk
All statements made are subject to Frontier's Terms and Conditions
of Business which are available upon request.