Implement support for wxHSCROLL in wxTextCtrl under OS X
Make the associated NSTextContainer of infinite size and tell it not to track the NSTextView width if wxHSCROLL is specified. Closes #4022. Closes https://github.com/wxWidgets/wxWidgets/pull/124
This commit is contained in:
parent
79f62505bb
commit
a118c4243a
@ -568,19 +568,28 @@ wxNSTextViewControl::wxNSTextViewControl( wxTextCtrl *wxPeer, WXWidget w, long s
|
||||
wxNSTextScrollView* sv = (wxNSTextScrollView*) w;
|
||||
m_scrollView = sv;
|
||||
|
||||
[m_scrollView setHasVerticalScroller:YES];
|
||||
[m_scrollView setHasHorizontalScroller:NO];
|
||||
// TODO Remove if no regression, this was causing automatic resizes of multi-line textfields when the tlw changed
|
||||
// [m_scrollView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
||||
NSSize contentSize = [m_scrollView contentSize];
|
||||
const bool hasHScroll = (style & wxHSCROLL) != 0;
|
||||
|
||||
wxNSTextView* tv = [[wxNSTextView alloc] initWithFrame: NSMakeRect(0, 0,
|
||||
contentSize.width, contentSize.height)];
|
||||
[m_scrollView setHasVerticalScroller:YES];
|
||||
[m_scrollView setHasHorizontalScroller:hasHScroll];
|
||||
NSSize contentSize = [m_scrollView contentSize];
|
||||
NSRect viewFrame = NSMakeRect(
|
||||
0, 0,
|
||||
hasHScroll ? FLT_MAX : contentSize.width, contentSize.height
|
||||
);
|
||||
|
||||
wxNSTextView* const tv = [[wxNSTextView alloc] initWithFrame: viewFrame];
|
||||
m_textView = tv;
|
||||
[tv setVerticallyResizable:YES];
|
||||
[tv setHorizontallyResizable:NO];
|
||||
[tv setHorizontallyResizable:hasHScroll];
|
||||
[tv setAutoresizingMask:NSViewWidthSizable];
|
||||
|
||||
if ( hasHScroll )
|
||||
{
|
||||
[[tv textContainer] setContainerSize:NSMakeSize(FLT_MAX, FLT_MAX)];
|
||||
[[tv textContainer] setWidthTracksTextView:NO];
|
||||
}
|
||||
|
||||
if ( style & wxTE_RIGHT)
|
||||
{
|
||||
[tv setAlignment:NSRightTextAlignment];
|
||||
|
Loading…
Reference in New Issue
Block a user