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.2KB

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