@@ -30,7 +30,7 @@ class UITextViewDelegateImpl extends NSObject implements UITextViewDelegate {
3030 public textViewShouldBeginEditing ( textView : UITextView ) : boolean {
3131 const owner = this . _owner . get ( ) ;
3232 if ( owner ) {
33- owner . showText ( ) ;
33+ return owner . textViewShouldBeginEditing ( textView ) ;
3434 }
3535
3636 return true ;
@@ -39,47 +39,28 @@ class UITextViewDelegateImpl extends NSObject implements UITextViewDelegate {
3939 public textViewDidBeginEditing ( textView : UITextView ) : void {
4040 const owner = this . _owner . get ( ) ;
4141 if ( owner ) {
42- owner . _isEditing = true ;
43- owner . notify ( { eventName : TextView . focusEvent , object : owner } ) ;
42+ owner . textViewDidBeginEditing ( textView ) ;
4443 }
4544 }
4645
47- public textViewDidEndEditing ( textView : UITextView ) {
46+ public textViewDidEndEditing ( textView : UITextView ) : void {
4847 const owner = this . _owner . get ( ) ;
4948 if ( owner ) {
50- if ( owner . updateTextTrigger === "focusLost" ) {
51- textProperty . nativeValueChange ( owner , textView . text ) ;
52- }
53-
54- owner . _isEditing = false ;
55- owner . dismissSoftInput ( ) ;
56- owner . _refreshHintState ( owner . hint , textView . text ) ;
49+ owner . textViewDidEndEditing ( textView ) ;
5750 }
5851 }
5952
60- public textViewDidChange ( textView : UITextView ) {
53+ public textViewDidChange ( textView : UITextView ) : void {
6154 const owner = this . _owner . get ( ) ;
6255 if ( owner ) {
63- if ( owner . updateTextTrigger === "textChanged" ) {
64- textProperty . nativeValueChange ( owner , textView . text ) ;
65- }
66- owner . requestLayout ( ) ;
56+ owner . textViewDidChange ( textView ) ;
6757 }
6858 }
6959
7060 public textViewShouldChangeTextInRangeReplacementText ( textView : UITextView , range : NSRange , replacementString : string ) : boolean {
7161 const owner = this . _owner . get ( ) ;
7262 if ( owner ) {
73- const delta = replacementString . length - range . length ;
74- if ( delta > 0 ) {
75- if ( textView . text . length + delta > owner . maxLength ) {
76- return false ;
77- }
78- }
79-
80- if ( owner . formattedText ) {
81- _updateCharactersInRangeReplacementString ( owner . formattedText , range . location , range . length , replacementString ) ;
82- }
63+ return owner . textViewShouldChangeTextInRangeReplacementText ( textView , range , replacementString ) ;
8364 }
8465
8566 return true ;
@@ -88,13 +69,7 @@ class UITextViewDelegateImpl extends NSObject implements UITextViewDelegate {
8869 public scrollViewDidScroll ( sv : UIScrollView ) : void {
8970 const owner = this . _owner . get ( ) ;
9071 if ( owner ) {
91- const contentOffset = owner . nativeViewProtected . contentOffset ;
92- owner . notify ( < ScrollEventData > {
93- object : owner ,
94- eventName : "scroll" ,
95- scrollX : contentOffset . x ,
96- scrollY : contentOffset . y
97- } ) ;
72+ return owner . scrollViewDidScroll ( sv ) ;
9873 }
9974 }
10075}
@@ -153,6 +128,59 @@ export class TextView extends TextViewBaseCommon {
153128 return this . nativeViewProtected ;
154129 }
155130
131+ public textViewShouldBeginEditing ( textView : UITextView ) : boolean {
132+ this . showText ( ) ;
133+
134+ return true ;
135+ }
136+
137+ public textViewDidBeginEditing ( textView : UITextView ) : void {
138+ this . _isEditing = true ;
139+ this . notify ( { eventName : TextView . focusEvent , object : this } ) ;
140+ }
141+
142+ public textViewDidEndEditing ( textView : UITextView ) : void {
143+ if ( this . updateTextTrigger === "focusLost" ) {
144+ textProperty . nativeValueChange ( this , textView . text ) ;
145+ }
146+
147+ this . _isEditing = false ;
148+ this . dismissSoftInput ( ) ;
149+ this . _refreshHintState ( this . hint , textView . text ) ;
150+ }
151+
152+ public textViewDidChange ( textView : UITextView ) : void {
153+ if ( this . updateTextTrigger === "textChanged" ) {
154+ textProperty . nativeValueChange ( this , textView . text ) ;
155+ }
156+ this . requestLayout ( ) ;
157+ }
158+
159+ public textViewShouldChangeTextInRangeReplacementText ( textView : UITextView , range : NSRange , replacementString : string ) : boolean {
160+ const delta = replacementString . length - range . length ;
161+ if ( delta > 0 ) {
162+ if ( textView . text . length + delta > this . maxLength ) {
163+ return false ;
164+ }
165+ }
166+
167+ if ( this . formattedText ) {
168+ _updateCharactersInRangeReplacementString ( this . formattedText , range . location , range . length , replacementString ) ;
169+ }
170+
171+ return true ;
172+ }
173+
174+ public scrollViewDidScroll ( sv : UIScrollView ) : void {
175+ const contentOffset = this . nativeViewProtected . contentOffset ;
176+ this . notify ( < ScrollEventData > {
177+ object : this ,
178+ eventName : "scroll" ,
179+ scrollX : contentOffset . x ,
180+ scrollY : contentOffset . y
181+ } ) ;
182+ }
183+
156184 public _refreshHintState ( hint : string , text : string ) {
157185 if ( this . formattedText ) {
158186 return ;
0 commit comments