Multi-line wxTextCtrl in tabbed dialogs

Hi,

Under W2K, when a wxTextCtrl within a dialog (with buttons and so on)
receives the focus via tabbing, it selects all the text. This is fine
and normal practice with single-line input fields. However, with multi-
line entry fields, I don't really like it because it is easy to his
space or suchlike and zap the entire contents. I'd prefer that the
cursor simply appears at the last insertion point as occurs when you
click (but this changes the insertion point!). I've tried installing
handlers for OnFocus and OnActivateFocus, and then calling
SetSelection() but without much luck.

Ideas?

Regards.

···

--
Pythonologist

Pythonologist wrote:

Hi,

Under W2K, when a wxTextCtrl within a dialog (with buttons and so on)
receives the focus via tabbing, it selects all the text. This is fine
and normal practice with single-line input fields. However, with multi-
line entry fields, I don't really like it because it is easy to his
space or suchlike and zap the entire contents. I'd prefer that the
cursor simply appears at the last insertion point as occurs when you
click (but this changes the insertion point!). I've tried installing
handlers for OnFocus and OnActivateFocus, and then calling
SetSelection() but without much luck.

Use wxCallafter in the EVT_SET_FOCUS handler so your SetSelection call will happen after the default focus handler selects the whole text.

  txt = event.GetEventObject()
  end = txt.GetLastPosition()
  wxCallAfter(txt.SetSelection, pos, pos)

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!