Fix Enter and Tab key issue in textfield 73/320373/3
authorMd. Shahrukh Islam/NC eXperience Group /SRBD/Engineer/Samsung Electronics <shahrukh.i@samsung.com>
Thu, 14 Nov 2024 06:18:46 +0000 (12:18 +0600)
committerMd. Shahrukh Islam/NC eXperience Group /SRBD/Engineer/Samsung Electronics <shahrukh.i@samsung.com>
Thu, 14 Nov 2024 12:42:06 +0000 (18:42 +0600)
[Problem][TNINE-5252] [RPi4][Target][32 bit][Key Input] For hardware keyboard, no form takes input of enter key and tab key
[Cause & Measure]
 Cause   : KeyEvent for textfield was not handled.
 Measure : Used KeyEvent of textfield for Enter and Tab key.

Change-Id: If1def1bae85611dcc9942c83e2e8c12d5c4dcc8e
Signed-off-by: Md. Shahrukh Islam/NC eXperience Group /SRBD/Engineer/Samsung Electronics <shahrukh.i@samsung.com>
music-player/Views/PlaylistView.cs

index a3c6e2c45c9da9644d265deacb853b90f2d5391c..e07e8f9305c6ae1e1300da0dd4b67732400c5308 100755 (executable)
@@ -19,6 +19,7 @@ namespace MusicPlayer.Views
         private TextLabel playlistTitleLabel;
         private Button playlistCreateButton;
         private PlaylistViewModel viewModel;
+        private AlertDialog alertDialog;
 
         public PlaylistView(PlaylistViewModel viewModel)
         {
@@ -187,6 +188,29 @@ namespace MusicPlayer.Views
                 HorizontalAlignment = HorizontalAlignment.Begin,
                 PixelSize = 32.SpToPx(),
             };
+
+            inputTextField.KeyEvent += (s, e) => {
+                if (e.Key.State == Key.StateType.Up)
+                {
+                    switch (e.Key.KeyPressedName)
+                    {
+                        case "Return":
+                            if (OnPlaylistCreate(inputTextField.Text))
+                            {
+                                RemoveAlertDialog(alertDialog);
+                            }
+                            return true;
+
+                        case "Tab":
+                            inputTextField.SelectText(0, inputTextField.Text.Length);
+                            return true;
+
+                        default:
+                            return false;
+                    }
+                }
+                return false;
+            };
             return inputTextField;
         }
 
@@ -365,7 +389,7 @@ namespace MusicPlayer.Views
             RelativeLayout.SetHorizontalAlignment(createButton, RelativeLayout.Alignment.End);
             RelativeLayout.SetVerticalAlignment(createButton, RelativeLayout.Alignment.Start);
 
-            AlertDialog alertDialog = new AlertDialog()
+            alertDialog = new AlertDialog()
             {
                 ThemeChangeSensitive = true,
                 StyleName = "Dialogs",
@@ -397,7 +421,7 @@ namespace MusicPlayer.Views
 
             createButton.Clicked += (object o, ClickedEventArgs e) =>
             {
-                if(OnPlaylistCreate(inputFiled.Text) == true)
+                if(OnPlaylistCreate(inputFiled.Text))
                 {
                     RemoveAlertDialog(alertDialog);
                 }