나무 숲

Xamarin / 확인버튼 클릭 시 다음 Entry로 이동 본문

Career/모바일

Xamarin / 확인버튼 클릭 시 다음 Entry로 이동

wood.forest 2020. 12. 12. 10:45

Move to next Entry if Enter key pressed

주로 회원가입 등 연속된 폼 입력을 채울 때 사용되는 스킬이다.

Completed Event를 사용한다.

 

Ex1. Move to Next Entry's End of the text

NameEntry.Completed += (sender, e) =>
{
    NameEntry.Unfocus();
    EmailEntry.Focus();
    EmailEntry.CursorPosition = EmailEntry.Text.Length;
};
EmailEntry.Completed += (sender, e) =>
{
    EmailEntry.Unfocus();
    PasswordEntry.Focus();
    PasswordEntry.CursorPosition = PasswordEntry.Text.Length;
};

Ex2. 단순 focus이며 이 경우 Cursor position은 0

NameEntry.Completed += (sender, e) =>
{
    NameEntry.Unfocus();
    EmailEntry.Focus();
};
EmailEntry.Completed += (sender, e) =>
{
    EmailEntry.Unfocus();
    PasswordEntry.Focus();
};

Ex3. 최종 융합

NameEntry.Completed += (sender, e) =>
{
    EmailEntry.Focus();
    EmailEntry.CursorPosition = EmailEntry.Text.Length;
};
EmailEntry.Completed += (sender, e) =>
{
    PasswordEntry.Focus();
    PasswordEntry.CursorPosition = PasswordEntry.Text.Length;
};

Caution. 이렇게 단독작성하는 경우 어느 Entry도 focus되지 않는다. (= keyboard 안뜨는데 Cursor는 찍혀있다)

NameEntry.Completed += (sender, e) => EmailEntry.CursorPosition = PasswordEntry.Text.Length;
EmailEntry.Completed += (sender, e) => PasswordEntry.CursorPosition = PasswordEntry.Text.Length;
728x90
반응형
Comments