@@ -22,8 +22,6 @@ public interface ITextAreaHandler
22
22
23
23
Range < int > lastSelection { get ; set ; }
24
24
int ? lastCaretIndex { get ; set ; }
25
-
26
- void PerformLayout ( ) ;
27
25
}
28
26
29
27
public class EtoTextAreaDelegate : NSTextViewDelegate
@@ -81,7 +79,7 @@ public EtoTextView(ITextAreaHandler handler)
81
79
{
82
80
Delegate = new EtoTextAreaDelegate { Handler = handler } ;
83
81
AutoresizingMask = NSViewResizingMask . WidthSizable | NSViewResizingMask . HeightSizable ;
84
- HorizontallyResizable = true ;
82
+ HorizontallyResizable = false ;
85
83
VerticallyResizable = true ;
86
84
Editable = true ;
87
85
RichText = false ;
@@ -92,15 +90,6 @@ public EtoTextView(ITextAreaHandler handler)
92
90
MaxSize = new CGSize ( float . MaxValue , float . MaxValue ) ;
93
91
TextContainer . WidthTracksTextView = true ;
94
92
}
95
-
96
- public override void Layout ( )
97
- {
98
- if ( MacView . NewLayout )
99
- base . Layout ( ) ;
100
- ( Handler as ITextAreaHandler ) ? . PerformLayout ( ) ;
101
- if ( ! MacView . NewLayout )
102
- base . Layout ( ) ;
103
- }
104
93
}
105
94
106
95
public class TextAreaHandler < TControl , TCallback > : MacView < NSTextView , TControl , TCallback > , TextArea . IHandler , ITextAreaHandler
@@ -294,19 +283,28 @@ public Font Font
294
283
295
284
public bool Wrap
296
285
{
297
- get
298
- {
299
- return Control . TextContainer . WidthTracksTextView ;
300
- }
286
+ get => Control . TextContainer . WidthTracksTextView ;
301
287
set
302
288
{
289
+ if ( value == Wrap )
290
+ return ;
291
+
303
292
if ( value )
304
293
{
294
+ Control . HorizontallyResizable = false ;
305
295
Control . TextContainer . WidthTracksTextView = true ;
306
- Control . NeedsLayout = true ;
296
+ if ( Widget . Loaded )
297
+ {
298
+ // shrink the control and text container to the current width of the visible rectangle
299
+ var width = Scroll . DocumentVisibleRect . Size . Width ;
300
+ Control . SetFrameSize ( new CGSize ( width , Control . Frame . Height ) ) ;
301
+ Control . TextContainer . Size = new CGSize ( width , float . MaxValue ) ;
302
+ Control . NeedsLayout = true ;
303
+ }
307
304
}
308
305
else
309
306
{
307
+ Control . HorizontallyResizable = true ;
310
308
Control . TextContainer . WidthTracksTextView = false ;
311
309
Control . TextContainer . ContainerSize = new CGSize ( float . MaxValue , float . MaxValue ) ;
312
310
}
@@ -414,15 +412,6 @@ TextArea ITextAreaHandler.Widget
414
412
get { return Widget ; }
415
413
}
416
414
417
- public void PerformLayout ( )
418
- {
419
- if ( Wrap )
420
- {
421
- // set width of content to the size of the control when wrapping
422
- Control . TextContainer . ContainerSize = new CGSize ( Scroll . DocumentVisibleRect . Size . Width , float . MaxValue ) ;
423
- }
424
- }
425
-
426
415
public TextReplacements TextReplacements
427
416
{
428
417
get
0 commit comments