Ejemplo n.º 1
0
 protected internal override bool OnKeyDown(char c)
 {
     if (c == '\b')
     {
         if (this.m_String.Length > 0)
         {
             if (this.m_OnBeforeTextChange != null)
             {
                 this.m_OnBeforeTextChange(this);
             }
             if (this.m_String.Length > 0)
             {
                 this.m_String = this.m_String.Substring(0, this.m_String.Length - 1);
                 if (this.m_OnTextChange != null)
                 {
                     this.m_OnTextChange(this.m_String, this);
                 }
             }
         }
     }
     else
     {
         if (c == '\r')
         {
             if (this.m_EnterButton == null)
             {
                 return(false);
             }
             this.m_EnterButton.Click();
             return(true);
         }
         if (c == '\t')
         {
             Gumps.TextBoxTab(this);
             return(true);
         }
         if (c < ' ')
         {
             return(false);
         }
         if (this.m_OnBeforeTextChange != null)
         {
             this.m_OnBeforeTextChange(this);
         }
         if (this.m_MaxChars >= 0)
         {
             if (this.m_String.Length >= this.m_MaxChars)
             {
                 return(false);
             }
         }
         else if (((this.m_Font.GetStringWidth((this.m_PassChar == '\0') ? string.Format(this.ShowCaret ? "{0}{1}_" : "{0}{1}", this.m_String, c) : string.Format(this.ShowCaret ? "{0}_" : "{0}", new string(this.m_PassChar, this.m_String.Length + 1))) + 3) + (this.m_Back.OffsetX * 2)) >= this.m_Width)
         {
             return(false);
         }
         this.m_String = this.m_String + c;
         if (this.m_OnTextChange != null)
         {
             this.m_OnTextChange(this.m_String, this);
         }
     }
     this.UpdateLabel(false, this.m_HFocus);
     return(true);
 }
Ejemplo n.º 2
0
 protected internal override bool OnKeyDown(char c)
 {
     if ((int)c == 8)
     {
         if (this.m_String.Length > 0)
         {
             if (this.m_OnBeforeTextChange != null)
             {
                 this.m_OnBeforeTextChange((Gump)this);
             }
             if (this.m_String.Length > 0)
             {
                 this.m_String = this.m_String.Substring(0, this.m_String.Length - 1);
                 if (this.m_OnTextChange != null)
                 {
                     this.m_OnTextChange(this.m_String, (Gump)this);
                 }
             }
         }
     }
     else
     {
         if ((int)c == 13)
         {
             if (this.m_EnterButton == null)
             {
                 return(false);
             }
             this.m_EnterButton.Click();
             return(true);
         }
         if ((int)c == 9)
         {
             Gumps.TextBoxTab((Gump)this);
             return(true);
         }
         if ((int)c < 32)
         {
             return(false);
         }
         if (this.m_OnBeforeTextChange != null)
         {
             this.m_OnBeforeTextChange((Gump)this);
         }
         if (this.m_MaxChars >= 0)
         {
             if (this.m_String.Length >= this.m_MaxChars)
             {
                 return(false);
             }
         }
         else if (this.m_Font.GetStringWidth((int)this.m_PassChar == 0 ? string.Format(this.ShowCaret ? "{0}{1}_" : "{0}{1}", (object)this.m_String, (object)c) : string.Format(this.ShowCaret ? "{0}_" : "{0}", (object)new string(this.m_PassChar, this.m_String.Length + 1))) + 3 + this.m_Back.OffsetX * 2 >= this.m_Width)
         {
             return(false);
         }
         this.m_String += (string)(object)c;
         if (this.m_OnTextChange != null)
         {
             this.m_OnTextChange(this.m_String, (Gump)this);
         }
     }
     this.UpdateLabel(false, this.m_HFocus);
     return(true);
 }