/// <summary> /// Handle text entered /// </summary> /// <param name="sender">Object sender</param> /// <param name="e">Event arguments</param> private void TextEntered(object sender, SFML.Window.TextEventArgs e) { if (GuiManager.CurrentFocus is TextBox) { TextBox tControl = (TextBox)GuiManager.CurrentFocus; tControl.Add(e.Unicode); } }
public void CharEntered(TextEventArgs e) { foreach (Element ele in Elements) { if (ele != null) ele.CharEntered(e); } OnCharEntered(e); }
/// <summary> /// Gets if the <see cref="TextEventArgs"/> contains one of the <see cref="CommonChars"/>. /// </summary> /// <param name="e">The <see cref="TextEventArgs"/>.</param> /// <returns>True if the <paramref name="e"/> contains one of the <see cref="CommonChars"/>; otherwise false.</returns> public static bool IsCommonKey(TextEventArgs e) { if (e.Unicode.Length != 1) return false; if (_commonChars.Contains(e.Unicode[0])) return true; return false; }
private void HandleTextEnter(object _, SFML.Window.TextEventArgs args) { switch (InputState) { case TInputState.Chat: if (args.Unicode.Any(c => char.IsControl(c) | "`~".Contains(c))) { break; } CommandBox += args.Unicode; break; } }
protected override void OnCharEntered(TextEventArgs e) { if (Focus && AllowInput) { if (e.Unicode == "\b" && Input.DisplayedString.Length > 0)// \b meaning backspace Input.DisplayedString = Input.DisplayedString.Remove(Input.DisplayedString.Length - 1, 1); else if (e.Unicode.Length == 1) { Input.DisplayedString += e.Unicode; } Size = new Vector2f(Input.CharacterSize * Input.DisplayedString.Length, Input.CharacterSize); } }
void Window_TextEntered(object sender, SFML.Window.TextEventArgs e) { if (!TextField.FieldActive) { if (Keyboard.IsKeyPressed(Keyboard.Key.Back)) { if (inputText.DisplayedString.Length > 0) { inputText.DisplayedString = inputText.DisplayedString.Substring(0, inputText.DisplayedString.Length - 1); } } else if (Keyboard.IsKeyPressed(Keyboard.Key.Return)) { SortInput.SortInputString(inputText.DisplayedString); //Add to input history. if (!string.IsNullOrWhiteSpace(inputText.DisplayedString) && !inputHistory.Contains(inputText.DisplayedString)) { if (inputHistory.Count > 6) { //Small List so this is fine. inputHistory.RemoveAt(0); } inputHistory.Add(inputText.DisplayedString); previousInputHistoryPosition = inputHistory.Count; } inputText.DisplayedString = ""; if (previousInputHistoryPosition >= 0) { inputHistoryPosition = previousInputHistoryPosition; } } else { inputText.DisplayedString += e.Unicode; } inputText.DisplayedString.Replace("\b", ""); } }
private void Window_TextEntered(object sender, SFML.Window.TextEventArgs e) { int output = (int)e.Unicode.ToCharArray()[0]; if (size < 11) { if (output >= 48 && output < 57) { inputText += e.Unicode; size++; } if (output > 64 && output < 91) { inputText += e.Unicode; size++; } if (output > 96 && output < 123) { size++; inputText += e.Unicode; } } if ((int)(e.Unicode.ToCharArray()[0]) == 8 && size > 0) { inputText = inputText.Remove(size - 1, 1); size--; } input.DisplayedString = inputText; if (output == 13 && size > 0) { window.TextEntered -= Window_TextEntered; window.MouseButtonPressed -= Window_MouseButtonPressed; game.Controller.Score.Name = inputText; game.Leaderboard.Add(inputText, game.Controller.Score); IsFinished = true; } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Tells the widget that text has been typed while the widget was focused /// </summary> /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected internal override void OnTextEntered(TextEventArgs e) { // If only numbers are supported then make sure the input is valid if (m_NumbersOnly) { if ((e.Unicode[0] < '0') || (e.Unicode[0] > '9')) { if ((e.Unicode[0] == '-') || (e.Unicode[0] == '+')) { if ((m_SelStart == 0) || (m_SelEnd == 0)) { if (m_Text.Length != 0) { // You can't have multiple + and - characters after each other if ((m_Text[0] == '-') || (m_Text[0] == '+')) return; } } else // + and - symbols are only allowed at the beginning of the line return; } else if ((e.Unicode[0] == ',') || (e.Unicode[0] == '.')) { // Only one comma is allowed foreach (char letter in m_Text) { if ((letter == ',') || (letter == '.')) return; } } else // Character not accepted return; } } // If there are selected characters then delete them first if (m_SelChars > 0) DeleteSelectedCharacters(); // Make sure we don't exceed our maximum characters limit if ((m_MaxChars > 0) && (m_Text.Length + 1 > m_MaxChars)) return; // Insert our character m_Text = m_Text.Insert((int)m_SelEnd, e.Unicode); // Change the displayed text if (m_PasswordChar != "") m_DisplayedText = m_DisplayedText.Insert((int)m_SelEnd, m_PasswordChar); else m_DisplayedText = m_DisplayedText.Insert((int)m_SelEnd, e.Unicode); // Append the character to the text m_TextFull.DisplayedString = m_DisplayedText; // Calculate the space inside the edit box float width; if (m_SplitImage) width = m_Size.X - ((m_Borders.Left + m_Borders.Right) * (m_Size.Y / m_TextureNormal_M.Size.Y)); else width = m_Size.X - ((m_Borders.Left + m_Borders.Right) * (m_Size.X / m_TextureNormal_M.Size.X)); // When there is a text width limit then reverse what we just did if (m_LimitTextWidth) { // Now check if the text fits into the EditBox if (m_TextFull.FindCharacterPos((uint)m_DisplayedText.Length).X > width) { // If the text does not fit in the EditBox then delete the added character m_Text = m_Text.Remove((int)m_SelEnd, 1); m_DisplayedText = m_DisplayedText.Remove((int)m_SelEnd, 1); return; } } // Move our selection point forward SetSelectionPointPosition(m_SelEnd + 1); // The selection point should be visible again m_SelectionPointVisible = true; m_AnimationTimeElapsed = 0; // Add the callback (if the user requested it) if (TextChangedCallback != null) { m_Callback.Trigger = CallbackTrigger.TextChanged; m_Callback.Text = m_Text; TextChangedCallback (this, m_Callback); } }
/// <summary> /// Handles the TextEntered event of the <see cref="GameBase.RenderWindow"/>. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="SFML.Window.TextEventArgs"/> instance containing the event data.</param> void rw_TextEntered(object sender, TextEventArgs e) { if (TextEntered != null) TextEntered.Raise(this, e); }
/// <summary> /// Handles when text has been entered into this <see cref="Control"/>. /// This is called immediately before <see cref="Control.TextEntered"/>. /// Override this method instead of using an event hook on <see cref="Control.TextEntered"/> when possible. /// </summary> /// <param name="e">The event args.</param> protected override void OnTextEntered(TextEventArgs e) { if (_editableTextHandler == null) return; if (!IsEnabled) return; if (IgnoreKeysHandler != null && IgnoreKeysHandler(e)) return; if (AllowKeysHandler != null && !AllowKeysHandler(e)) return; _editableTextHandler.HandleText(e); base.OnTextEntered(e); _hasTextChanged = true; }
public virtual void TextEntered(TextEventArgs e) { }
/// <summary> /// Notifies this <see cref="Control"/> about an event that took place on it. These events should usually come from the /// <see cref="IGUIManager"/> that manages this <see cref="Control"/> instance. /// </summary> /// <param name="e">The event arguments.</param> internal void SendTextEnteredEvent(TextEventArgs e) { if (!CanReceiveInputEvent) return; InvokeTextEntered(e); }
/// <summary> /// Invokes the corresponding virtual method and event for the given event. Use this instead of invoking /// the virtual method and event directly to ensure that the event is invoked correctly. /// </summary> /// <param name="e">The event args.</param> void InvokeTextEntered(TextEventArgs e) { OnTextEntered(e); var handler = Events[_eventTextEntered] as TypedEventHandler<Control, TextEventArgs>; if (handler != null) handler.Raise(this, e); }
public override bool TextEntered(TextEventArgs e) { foreach (GuiComponent component in components) if (component.TextEntered(e)) return true; return false; }
/// <summary> /// Protected overridable handler that raises TextEntered event. /// </summary> protected virtual void OnTextEntered(TextEventArgs args) { TextEntered?.Invoke(this, args); }
public virtual void OnTextEntered(TextEventArgs E) { }
public void TextEntered(TextEventArgs e) { if(ActiveWindow != null) ActiveWindow.TextEntered(e); }
public override bool TextEntered(TextEventArgs e) { if (Text.Length >= MaxCharacters || "\b\n\u001b\r".Contains(e.Unicode)) return false; Text = Text.Insert(_caretIndex, e.Unicode); if (_caretIndex < _text.Length) _caretIndex++; SetVisibleText(); return true; }
void TextEntered(object sender, TextEventArgs e) { if (e.Unicode != "\u0008" && e.Unicode != "\u001b" && e.Unicode != "\u000D") textInputString += e.Unicode; if (e.Unicode == "\u0008") { if (textInputString.Length > 0) textInputString = textInputString.Remove(textInputString.Length - 1); } }
public override void TextEntered(TextEventArgs e) { if(AllowInput) { if(e.Unicode == "\b" && CursorPosition > 0)// \b meaning backspace { //BoxText.DisplayedString = BoxText.DisplayedString.Remove(BoxText.DisplayedString.Length - 1, 1); BoxText.DisplayedString = BoxText.DisplayedString.Remove(CursorPosition - 1, 1); SetCursorPos(-1); } else if(e.Unicode.Length == 1) { if(e.Unicode == "\n" || e.Unicode == "\r") { //BoxText.DisplayedString += "\n"; BoxText.DisplayedString = BoxText.DisplayedString.Insert(CursorPosition, "\n"); SetCursorPos(1); } else if(e.Unicode != "\b") { if(sizeX - (BoxText.FindCharacterPos((uint)BoxText.DisplayedString.Length).X) < 5) { BoxText.DisplayedString = BoxText.DisplayedString.Insert(CursorPosition, "\n"); SetCursorPos(1); } BoxText.DisplayedString = BoxText.DisplayedString.Insert(CursorPosition, e.Unicode); SetCursorPos(1); } } } }
/// <summary> /// The list of actions performed for a character entered /// </summary> public static void TextEnteredActions(RenderWindow window, TextEventArgs charEntered) { char charValue = '\0'; char.TryParse(charEntered.Unicode, out charValue); // See the difference ? charValue is the character, not the key pressed. // For example here you can differentiate upper case with lower case : if ((charValue >= 'A') && (charValue <= 'Z')) { } if ((charValue >= 'a') && (charValue <= 'z')) { } switch (charValue) { case 'A': /*You can insert actions here for that particular case.*/ break; case 'a': /*You can insert actions here for that particular case.*/ break; /*Etc...*/ default: break; } }
/// <summary> /// Gets if the text in the <see cref="TextEventArgs"/> is a digit. /// Common edit-related keys, such as backspace, also return true. /// </summary> /// <param name="e">The <see cref="TextEventArgs"/>.</param> /// <returns>True if the <paramref name="e"/> is of the expected type; otherwise false.</returns> public static bool IsDigit(TextEventArgs e) { if (e.Unicode.Length != 1) return false; return char.IsDigit(e.Unicode[0]) || IsCommonKey(e); }
private void window_TextEntered(object sender, TextEventArgs e) { Canvas.TextEntered(e.Unicode); }
void InputSystem_CharEntered(object sender, TextEventArgs e) { if (screens.Count > 0) CurrentScreen.CharEntered(e); }
private void TextEntered(object sender, TextEventArgs e) { if (_stateManager != null) _stateManager.TextEntered(e); }
/// <summary> /// Handles when text has been entered into this <see cref="Control"/>. /// This is called immediately before <see cref="Control.TextEntered"/>. /// Override this method instead of using an event hook on <see cref="Control.TextEntered"/> when possible. /// </summary> /// <param name="e">The event args.</param> protected virtual void OnTextEntered(TextEventArgs e) { }
static void window_TextEntered(object sender, TextEventArgs e) { m_Input.ProcessMessage(e); }
public void TextEnteredEvent(Object sender, TextEventArgs e) { if (Keyboard.IsKeyPressed(Keyboard.Key.BackSpace)) { if (activeField.Length > 0) { activeField = activeField.Remove(activeField.Length - 1, 1); MainGame.soundInstances.Add(new SoundInstance(Content.GetSound("dryFireSfx.wav"), 1, 0, 1)); } } else if (Keyboard.IsKeyPressed(Keyboard.Key.Return)) { } else if (Keyboard.IsKeyPressed(Keyboard.Key.LControl)) { } else if (Keyboard.IsKeyPressed(Keyboard.Key.Escape)) { } else if (Keyboard.IsKeyPressed(Keyboard.Key.Tab)) { } else { if (activeField.Length < 20) { activeField.Append(e.Unicode); MainGame.soundInstances.Add(new SoundInstance(Content.GetSound("dryFireSfx.wav"), 1, 0, 1)); } } }
void renderWindow_TextEntered(object sender, TextEventArgs e) { if (TextEntered != null) { Console.WriteLine(e.Unicode); TextEntered(this, new TextEnteredEventArgs(e.Unicode)); } }
public void TextEntered(TextEventArgs e) { UserInterfaceManager.TextEntered(e); }
void OnTextEntered(object sender, TextEventArgs e) { if (locked) return; if (!commandInputEnabled) return; string hexValue = (Encoding.ASCII.GetBytes(e.Unicode)[0].ToString("X")); int ascii = (int.Parse(hexValue, NumberStyles.HexNumber)); if (e.Unicode == "\b") { if (keyString.Length > 0) { keyString = keyString.Remove(keyString.Length - 1, 1); } } else if (ascii >= 32 && ascii < 128) { keyString += e.Unicode; } }
/// <summary> /// Handles when text is requested to be inserted into this <see cref="EditableTextHandler"/>. /// </summary> /// <param name="e">The <see cref="TextEventArgs"/>.</param> public void HandleText(TextEventArgs e) { var s = e.Unicode; // Ensure we received a valid string if (string.IsNullOrEmpty(s)) return; switch (s) { case "\b": // Delete character Source.DeleteChar(); break; case "\r": // Line break Source.BreakLine(); break; default: // Make sure it is a valid character to insert if (!CanInsertChar(s)) return; // Insert the character Source.InsertChar(s); break; } }
/// <summary> /// Handles text entry for the console. /// </summary> /// <param name="e">The <see cref="TextEventArgs"/> instance containing the event data.</param> public void OnInput(TextEventArgs e) { if (!this.Enabled) { return; } if (char.IsControl(e.Unicode[0])) { return; } if (e.Unicode.Equals("`")) { return; } this.currentInput = this.currentInput.Insert(this.currentPos, e.Unicode); this.currentPos += e.Unicode.Length; }
void OnTextEntered(object sender, TextEventArgs e) { //convert unicode to ascii to check range later string hexValue = (Encoding.ASCII.GetBytes(e.Unicode)[0].ToString("X")); int ascii = (int.Parse(hexValue, NumberStyles.HexNumber)); if (e.Unicode == "\b") { if (KeyString.Length > 0) { KeyString = KeyString.Remove(KeyString.Length - 1, 1); } } else if (e.Unicode == "\r") { KeyString += "\n"; } else if (ascii >= 32 && ascii < 128) { //only add to keystring if actual character KeyString += e.Unicode; } }
public void CharEntered(TextEventArgs e) { OnCharEntered(e); }