/////////////////////////////////////////////////////////////////////////////
-// Name: textctrl.cpp
+// Name: src/mac/carbon/textctrl.cpp
// Purpose: wxTextCtrl
// Author: Stefan Csomor
// Modified by: Ryan Norton (MLTE GetLineLength and GetLineText)
m_maxLength = 0;
m_privateContextMenu = NULL;
+ m_triggerOnSetValue = true ;
}
wxTextCtrl::~wxTextCtrl()
GetPeer()->SetStringValue( str ) ;
- wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, m_windowId );
- event.SetString( GetValue() );
- event.SetEventObject( this );
- GetEventHandler()->ProcessEvent( event );
+ if ( m_triggerOnSetValue )
+ {
+ wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, m_windowId );
+ event.SetString( GetValue() );
+ event.SetEventObject( this );
+ GetEventHandler()->ProcessEvent( event );
+ }
}
void wxTextCtrl::SetMaxLength(unsigned long len)
int key = event.GetKeyCode() ;
bool eat_key = false ;
+ if ( key == 'a' && event.MetaDown() )
+ {
+ SelectAll() ;
+
+ return ;
+ }
+
if ( key == 'c' && event.MetaDown() )
{
if ( CanCopy() )
}
if ( !IsEditable() && key != WXK_LEFT && key != WXK_RIGHT && key != WXK_DOWN && key != WXK_UP && key != WXK_TAB &&
- !( key == WXK_RETURN && ( (m_windowStyle & wxPROCESS_ENTER) || (m_windowStyle & wxTE_MULTILINE) ) )
-// && key != WXK_PRIOR && key != WXK_NEXT && key != WXK_HOME && key != WXK_END
+ !( key == WXK_RETURN && ( (m_windowStyle & wxTE_PROCESS_ENTER) || (m_windowStyle & wxTE_MULTILINE) ) )
+// && key != WXK_PAGEUP && key != WXK_PAGEDOWN && key != WXK_HOME && key != WXK_END
)
{
// eat it
// Check if we have reached the max # of chars (if it is set), but still
// allow navigation and deletion
- if ( !IsMultiLine() && m_maxLength && GetValue().Length() >= m_maxLength &&
+ if ( !IsMultiLine() && m_maxLength && GetValue().length() >= m_maxLength &&
key != WXK_LEFT && key != WXK_RIGHT && key != WXK_TAB &&
- key != WXK_BACK && !( key == WXK_RETURN && (m_windowStyle & wxPROCESS_ENTER) )
+ key != WXK_BACK && !( key == WXK_RETURN && (m_windowStyle & wxTE_PROCESS_ENTER) )
)
{
// eat it, we don't want to add more than allowed # of characters
switch ( key )
{
case WXK_RETURN:
- if (m_windowStyle & wxPROCESS_ENTER)
+ if (m_windowStyle & wxTE_PROCESS_ENTER)
{
wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId);
event.SetEventObject( this );
wxTextPos wxMacTextControl::GetLastPosition() const
{
- return GetStringValue().Length() ;
+ return GetStringValue().length() ;
}
void wxMacTextControl::Replace( long from , long to , const wxString &val )
wxString content = GetStringValue() ;
lines = 1;
- for (size_t i = 0; i < content.Length() ; i++)
+ for (size_t i = 0; i < content.length() ; i++)
{
if (content[i] == '\r')
lines++;
// Find line first
int count = 0;
- for (size_t i = 0; i < content.Length() ; i++)
+ for (size_t i = 0; i < content.length() ; i++)
{
if (count == lineNo)
{
// Add chars in line then
wxString tmp;
- for (size_t j = i; j < content.Length(); j++)
+ for (size_t j = i; j < content.length(); j++)
{
if (content[j] == '\n')
return tmp;
// Find line first
int count = 0;
- for (size_t i = 0; i < content.Length() ; i++)
+ for (size_t i = 0; i < content.length() ; i++)
{
if (count == lineNo)
{
// Count chars in line then
count = 0;
- for (size_t j = i; j < content.Length(); j++)
+ for (size_t j = i; j < content.length(); j++)
{
count++;
if (content[j] == '\n')
void wxMacUnicodeTextControl::SetEditable(bool editable)
{
- SetData<Boolean>( 0 , kControlEditTextLockedTag , (Boolean) !editable ) ;
+#if 0 // leads to problem because text cannot be selected anymore
+ SetData<Boolean>( kControlEditTextPart , kControlEditTextLockedTag , (Boolean) !editable ) ;
+#endif
}
void wxMacUnicodeTextControl::GetSelection( long* from, long* to ) const
val.Remove( start , end - start ) ;
val.insert( start , str ) ;
SetStringValue( val ) ;
- SetSelection( start + str.Length() , start + str.Length() ) ;
+ SetSelection( start + str.length() , start + str.length() ) ;
#endif
}
(((UniChar*)*theText)[actualSize]) = 0 ;
wxMBConvUTF16 converter ;
size_t noChars = converter.MB2WC( NULL , (const char*)*theText , 0 ) ;
+ wxASSERT_MSG( noChars != wxCONV_FAILED, _T("Unable to count the number of characters in this string!") );
ptr = new wxChar[noChars + 1] ;
- noChars = converter.MB2WC( ptr , (const char*)*theText , noChars ) ;
+ noChars = converter.MB2WC( ptr , (const char*)*theText , noChars + 1 ) ;
+ wxASSERT_MSG( noChars != wxCONV_FAILED, _T("Conversion of string failed!") );
ptr[noChars] = 0 ;
HUnlock( theText ) ;
#endif