Example #1
0
 public virtual void ActivateByKeyboardReturn(int textID, string text)
 {
     if (Parent != null)
     {
         Parent.ActivateByKeyboardReturn(textID, text);
     }
 }
Example #2
0
        protected override void OnKeyboardInput(InputEventKeyboard e)
        {
            switch (e.KeyCode)
            {
            case WinKeys.Tab:
                Parent.KeyboardTabToNextFocus(this);
                break;

            case WinKeys.Enter:
                Parent.ActivateByKeyboardReturn(EntryID, Text);
                break;

            case WinKeys.Back:
                if (ReplaceDefaultTextOnFirstKeypress)
                {
                    Text = string.Empty;
                    ReplaceDefaultTextOnFirstKeypress = false;
                }
                else if (Text.Length > 0)
                {
                    int escapedLength;
                    if (EscapeCharacters.TryFindEscapeCharacterBackwards(Text, Text.Length - 1, out escapedLength))
                    {
                        Text = Text.Substring(0, Text.Length - escapedLength);
                    }
                    else
                    {
                        Text = Text.Substring(0, Text.Length - 1);
                    }
                }
                break;

            default:
                if (NumericOnly && !char.IsNumber(e.KeyChar))
                {
                    return;
                }

                if (ReplaceDefaultTextOnFirstKeypress)
                {
                    Text = string.Empty;
                    ReplaceDefaultTextOnFirstKeypress = false;
                }

                if (e.IsChar)
                {
                    string escapedCharacter;
                    if (EscapeCharacters.TryMatchChar(e.KeyChar, out escapedCharacter))
                    {
                        Text += escapedCharacter;
                    }
                    else
                    {
                        Text += e.KeyChar;
                    }
                }
                break;
            }
        }