Loading...
Searching...
No Matches
juce::TextInputTarget Class Referenceabstract

## Detailed Description

An abstract base class which can be implemented by components that function as text editors.

This class allows different types of text editor component to provide a uniform interface, which can be used by things like OS-specific input methods, on-screen keyboards, etc.

The documentation for this class was generated from the following file:

- juce_gui_basics/keyboard/juce_TextInputTarget.h

Inheritance diagram for juce::TextInputTarget:

## Public Types

enum | VirtualKeyboardType { textKeyboard = 0 , numericKeyboard , decimalKeyboard , urlKeyboard , emailAddressKeyboard , phoneNumberKeyboard , passwordKeyboard }
| A set of possible on-screen keyboard types, for use in the getKeyboardType() method. More...

## Public Member Functions

| TextInputTarget ()=default
virtual | ~TextInputTarget ()=default
| Destructor.
virtual bool | isTextInputActive () const =0
| Returns true if this input target is currently accepting input.
virtual Range< int > | getHighlightedRegion () const =0
| Returns the extents of the selected text region, or an empty range if nothing is selected,.
virtual void | setHighlightedRegion (const Range< int > &newRange)=0
| Sets the currently-selected text region.
virtual void | setTemporaryUnderlining (const Array< Range< int > > &underlinedRegions)=0
| Sets a number of temporarily underlined sections.
virtual String | getTextInRange (const Range< int > &range) const =0
| Returns a specified sub-section of the text.
virtual void | insertTextAtCaret (const String &textToInsert)=0
| Inserts some text, overwriting the selected text region, if there is one.
virtual int | getCaretPosition () const =0
| Returns the current index of the caret.
Rectangle< int > | getCaretRectangle () const
| Returns the position of the caret, relative to the component's origin.
virtual Rectangle< int > | getCaretRectangleForCharIndex (int characterIndex) const =0
| Returns the bounding box of the character at the given index.
virtual int | getTotalNumChars () const =0
| Returns the total number of codepoints in the string.
virtual int | getCharIndexForPoint (Point< int > point) const =0
| Returns the index closest to the given point.
virtual RectangleList< int > | getTextBounds (Range< int > textRange) const =0
| Returns the bounding box for a range of text in the editor.
virtual VirtualKeyboardType | getKeyboardType ()
| Returns the target's preference for the type of keyboard that would be most appropriate.

## Member Enums

## VirtualKeyboardType

enum juce::TextInputTarget::VirtualKeyboardType

A set of possible on-screen keyboard types, for use in the getKeyboardType() method.

Enumerator
textKeyboard |
numericKeyboard |
decimalKeyboard |
urlKeyboard |
emailAddressKeyboard |
phoneNumberKeyboard |
passwordKeyboard |

## Constructors and Destructors

## TextInputTarget()

juce::TextInputTarget::TextInputTarget | ( |  | ) |

default

## ~TextInputTarget()

virtual juce::TextInputTarget::~TextInputTarget | ( |  | ) |

virtual default

Destructor.

## Member Functions

## isTextInputActive()

virtual bool juce::TextInputTarget::isTextInputActive | ( |  | ) | const

pure virtual

Returns true if this input target is currently accepting input.

For example, a text editor might return false if it's in read-only mode.

Implemented in juce::CodeEditorComponent, and juce::TextEditor.

## getHighlightedRegion()

virtual Range< int > juce::TextInputTarget::getHighlightedRegion | ( |  | ) | const

pure virtual

Returns the extents of the selected text region, or an empty range if nothing is selected,.

Implemented in juce::CodeEditorComponent, and juce::TextEditor.

## setHighlightedRegion()

virtual void juce::TextInputTarget::setHighlightedRegion | ( | const Range< int > & | newRange | ) |

pure virtual

Sets the currently-selected text region.

Implemented in juce::CodeEditorComponent, and juce::TextEditor.

## setTemporaryUnderlining()

virtual void juce::TextInputTarget::setTemporaryUnderlining | ( | const Array< Range< int > > & | underlinedRegions | ) |

pure virtual

Sets a number of temporarily underlined sections.

This is needed by MS Windows input method UI.

Implemented in juce::CodeEditorComponent, and juce::TextEditor.

## getTextInRange()

virtual String juce::TextInputTarget::getTextInRange | ( | const Range< int > & | range | ) | const

pure virtual

Returns a specified sub-section of the text.

Implemented in juce::CodeEditorComponent, and juce::TextEditor.

## insertTextAtCaret()

virtual void juce::TextInputTarget::insertTextAtCaret | ( | const String & | textToInsert | ) |

pure virtual

Inserts some text, overwriting the selected text region, if there is one.

Implemented in juce::CodeEditorComponent, and juce::TextEditor.

## getCaretPosition()

virtual int juce::TextInputTarget::getCaretPosition | ( |  | ) | const

pure virtual

Returns the current index of the caret.

Implemented in juce::CodeEditorComponent, and juce::TextEditor.

Referenced by getCaretRectangle().

## getCaretRectangle()

Rectangle< int > juce::TextInputTarget::getCaretRectangle | ( |  | ) | const

inline

Returns the position of the caret, relative to the component's origin.

References getCaretPosition(), and getCaretRectangleForCharIndex().

## getCaretRectangleForCharIndex()

virtual Rectangle< int > juce::TextInputTarget::getCaretRectangleForCharIndex | ( | int | characterIndex | ) | const

pure virtual

Returns the bounding box of the character at the given index.

Implemented in juce::CodeEditorComponent, and juce::TextEditor.

Referenced by getCaretRectangle().

## getTotalNumChars()

virtual int juce::TextInputTarget::getTotalNumChars | ( |  | ) | const

pure virtual

Returns the total number of codepoints in the string.

Implemented in juce::CodeEditorComponent, and juce::TextEditor.

## getCharIndexForPoint()

virtual int juce::TextInputTarget::getCharIndexForPoint | ( | Point< int > | point | ) | const

pure virtual

Returns the index closest to the given point.

This is the location where the cursor might be placed after clicking at the given point in a text field.

Implemented in juce::CodeEditorComponent, and juce::TextEditor.

## getTextBounds()

virtual RectangleList< int > juce::TextInputTarget::getTextBounds | ( | Range< int > | textRange | ) | const

pure virtual

Returns the bounding box for a range of text in the editor.

As the range may span multiple lines, this method returns a RectangleList.

The bounds are relative to the component's top-left and may extend beyond the bounds of the component if the text is long and word wrapping is disabled.

Implemented in juce::CodeEditorComponent, and juce::TextEditor.

## getKeyboardType()

virtual VirtualKeyboardType juce::TextInputTarget::getKeyboardType | ( |  | ) |

inline virtual

Returns the target's preference for the type of keyboard that would be most appropriate.

This may be ignored, depending on the capabilities of the OS.

Reimplemented in juce::TextEditor.

References textKeyboard.

### Purchase

Get JUCE

### Discover

What's New in JUCE Features

### Learn

Documentaion Tutorials Made with JUCE Resources

### Support

JUCE Forum Newsletter Archive

### About

Contact Us JUCE Legal JUCE Licensing FAQ

### Events

Audio Developer Conference
© Raw Material Software Limited