Opened 6 years ago

Closed 6 years ago

#13728 closed defect (fixed)

[Cocoa] wxGetTextFromUser does not select text

Reported by: Auria Owned by:
Priority: normal Milestone:
Component: wxOSX Version:
Keywords: Cc:
Blocked By: Blocking:
Patch: no


Under wxOSX/Carbon and wxMSW, wxGetTextFromUser selects the default text by default, so that the user can just start typing and the new text overrides the default value. And it's done on purpose, wxTextEntryDialog (which is used by wxGetTextFromUser) contains this line :

    m_textctrl->SetSelection(-1, -1);

some time in the debugger revealed that the text is fully selected correctly, but that upon showing the dialog, a TransferDataToWindow call resets the selection

the actual backtrace of the call that unsets the selection is

#1  0x003966bb in wxNSTextFieldControl::SetSelection () at event.h:236
#2  0x0032f55c in wxTextEntry::SetInsertionPoint () at event.h:236
#3  0x004a8f4e in wxTextEntryBase::DoSetValue () at translation.h:254
#4  0x0047efbd in wxTextCtrlBase::SetValue () at event.h:236
#5  0x004acd25 in wxTextValidator::TransferToWindow () at translation.h:254
#6  0x004b8c28 in wxWindowBase::TransferDataToWindow () at translation.h:254
#7  0x004b15c5 in wxWindowBase::OnInitDialog () at translation.h:254
#8  0x004ddfbf in wxAppConsoleBase::CallEventHandler () at translation.h:254
#9  0x00618438 in wxEvtHandler::ProcessEventIfMatchesId () at strconv.h:364
#10 0x0061909c in wxEventHashTable::HandleEvent () at strconv.h:364
#11 0x0061914e in wxEvtHandler::TryHereOnly () at strconv.h:364
#12 0x0061919c in wxEvtHandler::ProcessEventLocally () at strconv.h:364
#13 0x00619211 in wxEvtHandler::ProcessEvent () at strconv.h:364
#14 0x004b5644 in wxWindowBase::InitDialog () at translation.h:254
#15 0x00031a1a in wxDialog::Show () at Note.h:126
#16 0x002ebaa5 in wxDialog::ShowModal () at event.h:236
#17 0x002e3a2e in wxGetTextFromUser () at event.h:236

(ignore the filenames and line numbers, seems like gdb got all confused about them)

Change History (1)

comment:1 Changed 6 years ago by VZ

  • Resolution set to fixed
  • Status changed from new to closed

(In [72897]) Don't move the insertion point if text didn't change in wxTextEntry.

This avoids accidentally resetting the selection if SetValue() is called again
with the same value.

Closes #13728.

Note: See TracTickets for help on using tickets.