Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

juce_TextInputTarget.h 3.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 6 technical preview.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. You may use this code under the terms of the GPL v3
  6. (see www.gnu.org/licenses).
  7. For this technical preview, this file is not subject to commercial licensing.
  8. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  9. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  10. DISCLAIMED.
  11. ==============================================================================
  12. */
  13. namespace juce
  14. {
  15. //==============================================================================
  16. /**
  17. An abstract base class which can be implemented by components that function as
  18. text editors.
  19. This class allows different types of text editor component to provide a uniform
  20. interface, which can be used by things like OS-specific input methods, on-screen
  21. keyboards, etc.
  22. @tags{GUI}
  23. */
  24. class JUCE_API TextInputTarget
  25. {
  26. public:
  27. //==============================================================================
  28. /** */
  29. TextInputTarget() = default;
  30. /** Destructor. */
  31. virtual ~TextInputTarget() = default;
  32. /** Returns true if this input target is currently accepting input.
  33. For example, a text editor might return false if it's in read-only mode.
  34. */
  35. virtual bool isTextInputActive() const = 0;
  36. /** Returns the extents of the selected text region, or an empty range if
  37. nothing is selected,
  38. */
  39. virtual Range<int> getHighlightedRegion() const = 0;
  40. /** Sets the currently-selected text region. */
  41. virtual void setHighlightedRegion (const Range<int>& newRange) = 0;
  42. /** Sets a number of temporarily underlined sections.
  43. This is needed by MS Windows input method UI.
  44. */
  45. virtual void setTemporaryUnderlining (const Array<Range<int>>& underlinedRegions) = 0;
  46. /** Returns a specified sub-section of the text. */
  47. virtual String getTextInRange (const Range<int>& range) const = 0;
  48. /** Inserts some text, overwriting the selected text region, if there is one. */
  49. virtual void insertTextAtCaret (const String& textToInsert) = 0;
  50. /** Returns the position of the caret, relative to the component's origin. */
  51. virtual Rectangle<int> getCaretRectangle() = 0;
  52. /** A set of possible on-screen keyboard types, for use in the
  53. getKeyboardType() method.
  54. */
  55. enum VirtualKeyboardType
  56. {
  57. textKeyboard = 0,
  58. numericKeyboard,
  59. decimalKeyboard,
  60. urlKeyboard,
  61. emailAddressKeyboard,
  62. phoneNumberKeyboard
  63. };
  64. /** Returns the target's preference for the type of keyboard that would be most appropriate.
  65. This may be ignored, depending on the capabilities of the OS.
  66. */
  67. virtual VirtualKeyboardType getKeyboardType() { return textKeyboard; }
  68. };
  69. } // namespace juce