protected override void HandleCopy() { if (selectionLength != 0) { var whatToCopy = DisplayedText.Substring( selectionStart, selectionLength); Clipboard.ClipboardImplementation.PushStringToClipboard( whatToCopy); } }
internal void RecalculateBoundingAndDisplayedText() { BoundingIgnoredSizeAndFlags = TextHandle.MeasureText(SpriteHandle, TextValue, FontDrawFlags.NoClip); DisplayedText = TextValue; Bounding = BoundingIgnoredSizeAndFlags; if (Bounding.Width - 4 > Width) { while (Bounding.Width - 4 > Width && DisplayedText.Length > 3) { DisplayedText = string.Concat(DisplayedText.Substring(0, DisplayedText.Length - 4), "..."); Bounding = TextHandle.MeasureText(SpriteHandle, DisplayedText, DrawFlags); } } // Recalculate the position rectangle RecalculatePositionRectangle(); // Preload the text TextHandle.PreloadText(DisplayedText); }
protected void UpdateToSelection() { if (selectionInstance != null && selectionLength > 0 && DisplayedText?.Length > 0) { selectionInstance.Visible = true; selectionInstance.XUnits = global::Gum.Converters.GeneralUnitType.PixelsFromSmall; var substring = DisplayedText.Substring(0, selectionStart); var firstMeasure = this.coreTextObject.BitmapFont.MeasureString(substring); selectionInstance.X = this.textComponent.X + firstMeasure; substring = DisplayedText.Substring(0, selectionStart + selectionLength); selectionInstance.Width = 1 + this.coreTextObject.BitmapFont.MeasureString(substring) - firstMeasure; } else if (selectionInstance != null) { selectionInstance.Visible = false; } }