Don't switch NSCell to single-line mode (wxOSX)
NSCell of a single-line wxTextCtrl cannot be just switched to the single-line mode because apart from restricting layout to a single line this also effectively blocks processing of the Return key. To restrict the contents of the cell to a single line we need to replace in wxTextEntryFormatter every new line character with space (this simulates what is done when NSCell works in native single-line mode). Closes #18183. Closes #18179. Closes #18101. See #12693.
This commit is contained in:
parent
51de736a58
commit
606dc18e5f
@ -173,15 +173,17 @@ NSView* wxMacEditHelper::ms_viewCurrentlyEdited = nil;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( forceUpper )
|
// wxTextEntryFormatter is always associated with single-line text entry (through wxNSTextFieldControl)
|
||||||
|
// so all new line characters should be replaced with spaces (like it is done in single-line NSCell).
|
||||||
|
NSString* lineStr = [*partialStringPtr stringByReplacingOccurrencesOfString: @"\n" withString: @" "];
|
||||||
|
|
||||||
|
NSString* newStr = forceUpper ? [lineStr uppercaseString] : lineStr;
|
||||||
|
|
||||||
|
if ( ![*partialStringPtr isEqual:newStr] )
|
||||||
{
|
{
|
||||||
NSString* upper = [*partialStringPtr uppercaseString];
|
*partialStringPtr = newStr;
|
||||||
if ( ![*partialStringPtr isEqual:upper] )
|
|
||||||
{
|
|
||||||
*partialStringPtr = upper;
|
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
@ -1190,6 +1192,8 @@ void wxNSTextFieldControl::Init(WXWidget w)
|
|||||||
[m_textField setDelegate: tf];
|
[m_textField setDelegate: tf];
|
||||||
m_selStart = m_selEnd = 0;
|
m_selStart = m_selEnd = 0;
|
||||||
m_hasEditor = [w isKindOfClass:[NSTextField class]];
|
m_hasEditor = [w isKindOfClass:[NSTextField class]];
|
||||||
|
|
||||||
|
GetFormatter(); // we always need to at least replace new line characters with spaces
|
||||||
}
|
}
|
||||||
|
|
||||||
wxNSTextFieldControl::~wxNSTextFieldControl()
|
wxNSTextFieldControl::~wxNSTextFieldControl()
|
||||||
@ -1470,7 +1474,6 @@ void wxNSTextFieldControl::SetJustification()
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
|
||||||
wxWidgetImplType* wxWidgetImpl::CreateTextControl( wxTextCtrl* wxpeer,
|
wxWidgetImplType* wxWidgetImpl::CreateTextControl( wxTextCtrl* wxpeer,
|
||||||
wxWindowMac* WXUNUSED(parent),
|
wxWindowMac* WXUNUSED(parent),
|
||||||
wxWindowID WXUNUSED(id),
|
wxWindowID WXUNUSED(id),
|
||||||
@ -1508,7 +1511,8 @@ wxWidgetImplType* wxWidgetImpl::CreateTextControl( wxTextCtrl* wxpeer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
NSTextFieldCell* cell = [v cell];
|
NSTextFieldCell* cell = [v cell];
|
||||||
[cell setUsesSingleLineMode:YES];
|
[cell setWraps:NO];
|
||||||
|
[cell setScrollable:YES];
|
||||||
|
|
||||||
c = new wxNSTextFieldControl( wxpeer, wxpeer, v );
|
c = new wxNSTextFieldControl( wxpeer, wxpeer, v );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user