From: Stefan Csomor Date: Thu, 28 Aug 2003 14:42:02 +0000 (+0000) Subject: -1 , -1 for SetSelection improved X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/ea161895691ab197aacced56bd4792a3ffc31481 -1 , -1 for SetSelection improved git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23272 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/mac/carbon/textctrl.cpp b/src/mac/carbon/textctrl.cpp index a289930a71..d84050093d 100644 --- a/src/mac/carbon/textctrl.cpp +++ b/src/mac/carbon/textctrl.cpp @@ -1202,17 +1202,19 @@ void wxTextCtrl::Remove(long from, long to) void wxTextCtrl::SetSelection(long from, long to) { - if ( from == -1 ) - from = 0; - - if ( to == -1 ) - to = GetLastPosition(); - if ( !m_macUsesTXN ) { ControlEditTextSelectionRec selection ; - selection.selStart = from ; - selection.selEnd = to ; + if ((from == -1) && (to == -1)) + { + selection.selStart = 0 ; + selection.selEnd = 32767 ; + } + else + { + selection.selStart = from ; + selection.selEnd = to ; + } TESetSelect( selection.selStart , selection.selEnd , ((TEHandle) m_macTE) ) ; ::SetControlData((ControlHandle) m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ; @@ -1226,7 +1228,10 @@ void wxTextCtrl::SetSelection(long from, long to) may force a redraw in the text area. */ SetPort((**tpvars).fDrawingEnvironment); /* change the selection */ - TXNSetSelection( (**tpvars).fTXNRec, from, to); + if ((from == -1) && (to == -1)) + TXNSelectAll((TXNObject) m_macTXN); + else + TXNSetSelection( (**tpvars).fTXNRec, from, to); TXNShowSelection( (TXNObject) m_macTXN, kTXNShowStart); } } diff --git a/src/mac/textctrl.cpp b/src/mac/textctrl.cpp index a289930a71..d84050093d 100644 --- a/src/mac/textctrl.cpp +++ b/src/mac/textctrl.cpp @@ -1202,17 +1202,19 @@ void wxTextCtrl::Remove(long from, long to) void wxTextCtrl::SetSelection(long from, long to) { - if ( from == -1 ) - from = 0; - - if ( to == -1 ) - to = GetLastPosition(); - if ( !m_macUsesTXN ) { ControlEditTextSelectionRec selection ; - selection.selStart = from ; - selection.selEnd = to ; + if ((from == -1) && (to == -1)) + { + selection.selStart = 0 ; + selection.selEnd = 32767 ; + } + else + { + selection.selStart = from ; + selection.selEnd = to ; + } TESetSelect( selection.selStart , selection.selEnd , ((TEHandle) m_macTE) ) ; ::SetControlData((ControlHandle) m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ; @@ -1226,7 +1228,10 @@ void wxTextCtrl::SetSelection(long from, long to) may force a redraw in the text area. */ SetPort((**tpvars).fDrawingEnvironment); /* change the selection */ - TXNSetSelection( (**tpvars).fTXNRec, from, to); + if ((from == -1) && (to == -1)) + TXNSelectAll((TXNObject) m_macTXN); + else + TXNSetSelection( (**tpvars).fTXNRec, from, to); TXNShowSelection( (TXNObject) m_macTXN, kTXNShowStart); } }