示例#1
0
        void TextEntered(object sender, TextInputEventArgs e)
        {
            if (editingString == null)
                return;

            char c = e.Character;

            //OpenGL doesn't pass special characters this way,
            //so we have to handle them elsewhere
            //but we have to handle them here for other platforms
            #if OpenGL
            editingString.Append(c);
            #else
            switch (c)
            {
                case '\b':
                    //backspace
                    if (editingString.Length == 0)
                        break;
                    editingString.Remove(editingString.Length - 1, 1);
                    break;
                case '\n':
                    //enter is handled elsewhere
                    break;
                default:
                    editingString.Append(c);
                    break;
            }
            #endif
        }
示例#2
0
 public void OnTextInput(Object sender, TextInputEventArgs e) {
 char c = e.Character;
 #endif
     if (FocusedWidget != null) {
         FocusedWidget.TextInput(c);
     }
 }
示例#3
0
        private void Manager_OnTextInput(object sender, TextInputEventArgs e)
        {
            if (m_HasFocus)
            {
                if (m_Mode != TextEditMode.ReadOnly)
                {
                    if (m_NumLines > 1)
                    {
                        //Check that text doesn't go beyond width of control...
                        if ((m_Font.MeasureString(m_Lines[m_Cursor.LineIndex].SBuilder.ToString()).X >=
                            m_Size.X) && !m_RemovingTxt && !m_MovingCursor)
                        {
                            if (m_TextPosition.Y <= Position.Y + ((m_NumLines - 2) * m_Font.LineSpacing))
                            {
                                m_TextPosition.Y += m_Font.LineSpacing;
                                m_Lines.Add(new RenderableText() { SBuilder = new StringBuilder(), Position = m_TextPosition });

                                m_Cursor.Position.Y += m_Font.LineSpacing;
                                m_Cursor.LineIndex++;
                                m_Cursor.CharacterIndex = 0;
                            }
                            else //Text went beyond the borders of the control...
                            {
                                foreach (RenderableText Txt in m_Lines)
                                    Txt.Position.Y -= m_Font.LineSpacing;

                                m_Lines.Add(new RenderableText() { SBuilder = new StringBuilder(), Position = m_TextPosition });
                                m_ScrollbarHeight -= m_Font.LineSpacing; //TODO: Resize scrollbar...

                                m_Cursor.LineIndex++;
                                m_Cursor.CharacterIndex = 0;

                                m_Lines[m_VisibilityIndex].Visible = false;
                                m_VisibilityIndex++;
                            }

                            m_Cursor.Position.X = Position.X;
                        }
                    }
                    else
                    {
                        //Text went beyond the borders of the control...
                        if (m_Font.MeasureString(CurrentInput).X >= (m_Size.X -
                            m_Font.MeasureString(e.Character.ToString()).X) && !m_RemovingTxt)
                        {
                            m_Lines.Add(new RenderableText() { SBuilder = new StringBuilder(), Position = m_Cursor.Position, Visible = true });
                            m_Cursor.Position.X = m_Size.X;
                            //In a single line control, each "line" will hold one character.
                            m_Cursor.LineIndex++;

                            foreach (RenderableText Txt in m_Lines)
                            {
                                Txt.Position.X -= m_Font.MeasureString(e.Character.ToString()).X;

                                if (Txt.Position.X < Position.X)
                                    Txt.Visible = false;
                            }
                        }
                        else
                        {
                            m_Lines.Add(new RenderableText() { SBuilder = new StringBuilder(), Position = m_Cursor.Position, Visible = true});
                            //In a single line control, each "line" will hold one character.
                            m_Cursor.LineIndex++;
                        }
                    }
                }

                if (!m_IsUpperCase)
                {
                    //If the cursor is in the middle of a line, replace the character.
                    if (m_NumLines > 1)
                    {
                        if (m_Cursor.CharacterIndex < m_Lines[m_Cursor.LineIndex].SBuilder.Length)
                            m_Lines[m_Cursor.LineIndex].SBuilder[m_Cursor.CharacterIndex] = e.Character;
                        else
                            m_Lines[m_Cursor.LineIndex].SBuilder.Append(e.Character);
                    }
                    else
                    {
                        if (m_Cursor.CharacterIndex < CurrentInput.Length)
                            m_Lines[m_Cursor.LineIndex].SBuilder[0] = e.Character;
                        else
                        {
                            RenderableText Txt = new RenderableText();
                            Txt.SBuilder = new StringBuilder(e.Character.ToString());
                            Txt.Position = m_Cursor.Position;
                            Txt.Visible = true;
                            m_Lines.Insert(m_Cursor.LineIndex, Txt);
                        }
                    }
                }
                else
                {
                    if (m_NumLines > 1)
                    {
                        //If the cursor is in the middle of a line, replace the character.
                        if (m_Cursor.CharacterIndex < m_Lines[m_Cursor.LineIndex].SBuilder.Length)
                            m_Lines[m_Cursor.LineIndex].SBuilder[m_Cursor.CharacterIndex] = e.Character.ToString().ToUpper().ToCharArray()[0];
                        else
                            m_Lines[m_Cursor.LineIndex].SBuilder.Append(e.Character.ToString().ToUpper());
                    }
                    else
                    {
                        if ((m_Cursor.CharacterIndex < CurrentInput.Length) && m_MovingCursor)
                            m_Lines[m_Cursor.LineIndex].SBuilder[0] = e.Character;
                        else
                        {
                            RenderableText Txt = new RenderableText();
                            Txt.SBuilder = new StringBuilder(e.Character.ToString().ToUpper());
                            Txt.Position = m_Cursor.Position;
                            Txt.Visible = true;
                            m_Lines.Insert(m_Cursor.LineIndex, Txt);
                        }
                    }
                }

                m_Cursor.CharacterIndex++;
                m_RemovingTxt = false;
                m_MovingCursor = false;
                m_Cursor.Position.X += m_Font.MeasureString(e.Character.ToString()).X;
            }
        }
示例#4
0
		protected void OnTextInput(object sender, TextInputEventArgs e)
		{
			if (TextInput != null)
				TextInput(sender, e);
		}
示例#5
0
 protected void OnTextInput(object sender, TextInputEventArgs e)
 {
     EventHelpers.Raise(this, TextInput, e);
 }
示例#6
0
		protected void OnTextInput(TextInputEventArgs e)
		{
			if (e == null) 
			{
				throw new ArgumentNullException("e");
			}
			
			if (TextInput != null) 
			{
				TextInput.Invoke(this, e);
			}
		}
示例#7
0
 private void Window_TextInput(object sender, TextInputEventArgs e)
 {
     OnCharacterInput?.Invoke(this, e);
 }
示例#8
0
 void RawHandler(object sender, TextInputEventArgs eventArgs)
 {
     OnInput(InputMessage.MessageType.RawInput, false, eventArgs.Character);
 }
示例#9
0
 /// <summary>
 /// Called when the window receives text input. Raises the <see cref="TextInput"/> event.
 /// </summary>
 /// <param name="sender">The game window.</param>
 /// <param name="e">Parameters to the <see cref="TextInput"/> event.</param>
 internal void OnTextInput(TextInputEventArgs e)
 {
     EventHelpers.Raise(this, TextInput, e);
 }
示例#10
0
 private void Window_TextInput(object sender, Microsoft.Xna.Framework.TextInputEventArgs e)
 {
     OnTextInput(new TextInputEventArgs(e.Character, e.Key));
 }
示例#11
0
 public static void TextInput(object sender, TextInputEventArgs e)
 {
     TextCharacters.Add(e.Character);
 }
示例#12
0
 protected void OnTextInput(object sender, TextInputEventArgs e)
 {
   if (this.TextInput == null)
     return;
   this.TextInput(sender, e);
 }
 /// <summary>
 /// This should be called by an instance of Microsoft.XNA.Game.Window
 /// whenever it receives text input. This method will call the 
 /// OnTextInput event.
 /// </summary>
 /// <param name="Sender">The object that invoked this event, sent by the callee of this method.</param>
 /// <param name="TInputEArgs">A TextInputEventArgs instance, sent by the callee of this method.</param>
 public void ReceivedTextInput(object Sender, TextInputEventArgs TInputEArgs)
 {
     OnTextInput?.Invoke(Sender, TInputEArgs);
 }
示例#14
0
 private void Window_TextInput(object sender, TextInputEventArgs e)
 {
     if (m_ScrManager != null)
         m_ScrManager.ReceivedTextInput(sender, e);
 }