Beispiel #1
0
    public void OnNumPadKeyPressed(NumPadKeyType type)
    {
        if (type == NumPadKeyType.Enter)
        {
            Submit();
        }
        else if (type == NumPadKeyType.Clear)
        {
            // clear
            stringBuilder.Clear();
            InvokeCodeChanged();
        }
        else
        {
            // digit numeral

            if (clearAfterMaxLength && stringBuilder.Length >= maxLength)
            {
                stringBuilder.Clear();
            }

            if (stringBuilder.Length < maxLength)
            {
                stringBuilder.Append(GetChar(type));
                InvokeCodeChanged();

                if (submitAtMaxLength && stringBuilder.Length == maxLength)
                {
                    Submit();
                }
            }
        }
    }
Beispiel #2
0
 public static char GetChar(NumPadKeyType type)
 {
     if (type == NumPadKeyType.Enter)
     {
         return(' ');
     }
     else if (type == NumPadKeyType.Clear)
     {
         return('*');
     }
     else
     {
         return((char)((int)'0' + (int)type));
     }
 }