## wxCaret

A caret is a blinking cursor showing the position where the typed text will appear. The text controls usually have a caret but wxCaret class also allows to use a caret in other windows.

Currently, the caret appears as a rectangle of the given size. In the future, it will be possible to specify a bitmap to be used for the caret shape.

A caret is always associated with a window and the current caret can be retrieved using wxWindow::GetCaret. The same caret can't be reused in two different windows.

Derived from

No base class

Include files

<wx/caret.h>

Data structures

Members

wxCaret::wxCaret
wxCaret::Create
wxCaret::GetBlinkTime
wxCaret::GetPosition
wxCaret::GetSize
wxCaret::GetWindow
wxCaret::Hide
wxCaret::IsOk
wxCaret::IsVisible
wxCaret::Move
wxCaret::SetBlinkTime
wxCaret::SetSize
wxCaret::Show

### wxCaret::wxCaret

wxCaret()

Default constructor: you must use one of Create() functions later.

wxCaret(wxWindow* window, int width, int height)

wxCaret(wxWindowBase* window, const wxSize& size)

Create the caret of given (in pixels) width and height and associates it with the given window.

### wxCaret::Create

bool Create(wxWindowBase* window, int width, int height)

bool Create(wxWindowBase* window, const wxSize& size)

Create the caret of given (in pixels) width and height and associates it with the given window (same as constructor).

### wxCaret::GetBlinkTime

static int GetBlinkTime()

Returns the blink time which is measured in milliseconds and is the time elapsed between 2 inversions of the caret (blink time of the caret is the same for all carets, so this functions is static).

### wxCaret::GetPosition

void GetPosition(int* x, int* y) const

wxPoint GetPosition() const

Get the caret position (in pixels).

wxPerl note: In wxPerl there are two methods instead of a single overloaded method:

GetPosition() | Returns a Wx::Point
GetPositionXY() | Returns a 2-element list `( x, y )`

### wxCaret::GetSize

void GetSize(int* width, int* height) const

wxSize GetSize() const

Get the caret size.

wxPerl note: In wxPerl there are two methods instead of a single overloaded method:

GetSize() | Returns a Wx::Size
GetSizeWH() | Returns a 2-element list `( width, height )`

### wxCaret::GetWindow

wxWindow* GetWindow() const

Get the window the caret is associated with.

### wxCaret::Hide

void Hide()

Same as wxCaret::Show(false).

### wxCaret::IsOk

bool IsOk() const

Returns true if the caret was created successfully.

### wxCaret::IsVisible

bool IsVisible() const

Returns true if the caret is visible and false if it is permanently hidden (if it is is blinking and not shown currently but will be after the next blink, this method still returns true).

### wxCaret::Move

void Move(int x, int y)

void Move(const wxPoint& pt)

Move the caret to given position (in logical coordinates).

### wxCaret::SetBlinkTime

static void SetBlinkTime(int milliseconds)

Sets the blink time for all the carets.

Remarks

Under Windows, this function will change the blink time for all carets permanently (until the next time it is called), even for the carets in other applications.

See also

GetBlinkTime

### wxCaret::SetSize

void SetSize(int width, int height)

void SetSize(const wxSize& size)

Changes the size of the caret.

### wxCaret::Show

void Show(bool show = true)

Shows or hides the caret. Notice that if the caret was hidden N times, it must be shown N times as well to reappear on the screen.