@@ -344,6 +344,13 @@ void SetBinding()
344
344
_textBox . SetBinding ( SfEntryView . IsVisibleProperty , "IsVisible" ) ;
345
345
_textBox . SetBinding ( SfEntryView . CursorPositionProperty , "CursorPosition" , BindingMode . TwoWay ) ;
346
346
_textBox . SetBinding ( SfEntryView . SelectionLengthProperty , "SelectionLength" , BindingMode . TwoWay ) ;
347
+
348
+ #if WINDOWS
349
+ if ( _textBox . Text != null )
350
+ {
351
+ _textBox . CursorPosition = _textBox . Text . Length ;
352
+ }
353
+ #endif
347
354
}
348
355
}
349
356
@@ -700,12 +707,12 @@ void AndroidEntry_AfterTextChanged(object? sender, Android.Text.AfterTextChanged
700
707
string decimalSeparator = GetNumberDecimalSeparator ( GetNumberFormat ( ) ) ;
701
708
if ( entry != null && ( entry . Text == "-" || entry . Text == decimalSeparator ) )
702
709
{
703
- if ( ! IsSamsungDevice ( ) && _textBox != null )
710
+ if ( ! _isSamsungWithSamsungKeyboard && _textBox != null )
704
711
{
705
712
_textBox . Text = AllowNull ? string . Empty : "0" ;
706
713
}
707
714
}
708
- if ( IsSamsungDevice ( ) && _textBox != null && _textBox . Text . Length > 1 )
715
+ if ( _isSamsungWithSamsungKeyboard && _textBox != null && _textBox . Text . Length > 1 )
709
716
{
710
717
if ( _textBox . Text [ 0 ] == decimalSeparator [ 0 ] && _textBox . Text . LastIndexOf ( decimalSeparator ) == 0 )
711
718
{
@@ -725,13 +732,21 @@ void AndroidEntry_AfterTextChanged(object? sender, Android.Text.AfterTextChanged
725
732
}
726
733
727
734
/// <summary>
728
- /// Validate the device is Samsung.
735
+ /// Validate the device is Samsung and which keyboard is used .
729
736
/// </summary>
730
- /// <returns>It returns <c>True</c> if the device is Samsung</returns>
731
- bool IsSamsungDevice ( )
732
- {
733
- return string . Equals ( global ::Android . OS . Build . Manufacturer , "samsung" , StringComparison . OrdinalIgnoreCase ) ;
734
- }
737
+ void CheckDeviceAndKeyboard ( )
738
+ {
739
+ if ( string . Equals ( global ::Android . OS . Build . Manufacturer , "samsung" , StringComparison . OrdinalIgnoreCase ) )
740
+ {
741
+ var context = Android . App . Application . Context ;
742
+ string currentKeyboard = KeyboardChecker . GetCurrentKeyboard ( context ) ;
743
+ _isSamsungWithSamsungKeyboard = currentKeyboard == "Samsung Keyboard" ;
744
+ }
745
+ else
746
+ {
747
+ _isSamsungWithSamsungKeyboard = false ;
748
+ }
749
+ }
735
750
736
751
#endif
737
752
@@ -1590,6 +1605,9 @@ void OnLoaded(object? sender, EventArgs e)
1590
1605
{
1591
1606
SetFlowDirection ( ) ;
1592
1607
}
1608
+
1609
+ #elif ANDROID
1610
+ CheckDeviceAndKeyboard ( ) ;
1593
1611
#endif
1594
1612
1595
1613
}
@@ -1872,7 +1890,7 @@ void ProcessDisplayTextForPlatform(ref string displayText)
1872
1890
1873
1891
#if ANDROID
1874
1892
// Prefix zero if needed, except on Samsung devices
1875
- if ( ! IsSamsungDevice ( ) )
1893
+ if ( ! _isSamsungWithSamsungKeyboard )
1876
1894
{
1877
1895
PrefixZeroIfNeeded ( ref displayText , IsNegative ( displayText , GetNumberFormat ( ) ) , GetNumberFormat ( ) ) ;
1878
1896
}
@@ -1985,7 +2003,7 @@ void UpdateCursorPosition(int decimalIndex, int caretPosition, string displayTex
1985
2003
return ;
1986
2004
}
1987
2005
#if ANDROID
1988
- if ( ! IsSamsungDevice ( ) )
2006
+ if ( ! _isSamsungWithSamsungKeyboard )
1989
2007
{
1990
2008
_cursorPosition = decimalIndex + 1 ;
1991
2009
}
@@ -2074,7 +2092,7 @@ void HandleNegativeKey(bool isNegative, int caretPosition)
2074
2092
#endif
2075
2093
}
2076
2094
#if ANDROID
2077
- else if ( displayText . StartsWith ( '. ') && IsSamsungDevice ( ) )
2095
+ else if ( displayText . StartsWith ( '. ') && _isSamsungWithSamsungKeyboard )
2078
2096
{
2079
2097
string decimalSeparator = GetNumberDecimalSeparator ( GetNumberFormat ( ) ) ;
2080
2098
displayText = string . Concat ( "" , displayText . AsSpan ( 1 ) ) ;
@@ -2360,6 +2378,13 @@ private void UpdateTextBoxCursorPosition(string displayText, int caretPosition)
2360
2378
}
2361
2379
2362
2380
_textBox . Text = displayText ;
2381
+ if ( ValueChangeMode == ValueChangeMode . OnKeyFocus && _textBox . Text != null && _textBox . Text != displayText )
2382
+ {
2383
+ if ( Parse ( _textBox . Text ) == Maximum )
2384
+ {
2385
+ caretPosition = _textBox . Text . Length ;
2386
+ }
2387
+ }
2363
2388
if ( _textBox . Text != null )
2364
2389
{
2365
2390
_textBox . CursorPosition = caretPosition >= 0 ? ( caretPosition <= _textBox . Text . Length ) ? caretPosition : _textBox . Text . Length : 0 ;
@@ -2379,6 +2404,9 @@ private void UpdateTextBoxCursorPosition(string displayText, int caretPosition)
2379
2404
/// <param name="caretPosition">The position of the caret where input should be inserted.</param>
2380
2405
void InsertNumbers ( string displayText , string selectedText , string input , int caretPosition )
2381
2406
{
2407
+ #if WINDOWS
2408
+ displayText ??= "" ;
2409
+ #endif
2382
2410
displayText = displayText . Remove ( caretPosition , Math . Min ( selectedText . Length , displayText . Length - caretPosition ) ) ;
2383
2411
string negativeSign = GetNegativeSign ( GetNumberFormat ( ) ) ;
2384
2412
bool isNegative = IsNegative ( displayText , GetNumberFormat ( ) ) ;
@@ -2541,7 +2569,11 @@ internal void UpdateDisplayText(double? value, bool resetCursor = true)
2541
2569
}
2542
2570
}
2543
2571
2572
+ #if WINDOWS
2573
+ if ( ( resetCursor || _isFirst ) && _textBox . Text != null )
2574
+ #else
2544
2575
if ( resetCursor && _textBox . Text != null )
2576
+ #endif
2545
2577
{
2546
2578
_textBox . CursorPosition = _textBox . Text . Length ;
2547
2579
}
0 commit comments