From: Md. Shahrukh Islam/NC eXperience Group /SRBD/Engineer/Samsung Electronics Date: Thu, 14 Nov 2024 06:18:46 +0000 (+0600) Subject: Fix Enter and Tab key issue in textfield X-Git-Tag: accepted/tizen/unified/20241202.132933~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7d91f48c7321165734044015f919f52fc25d007a;p=profile%2Fiot%2Fapps%2Fdotnet%2Fmusic-player.git Fix Enter and Tab key issue in textfield [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 --- diff --git a/music-player/Views/PlaylistView.cs b/music-player/Views/PlaylistView.cs index a3c6e2c..e07e8f9 100755 --- a/music-player/Views/PlaylistView.cs +++ b/music-player/Views/PlaylistView.cs @@ -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); }