Code: Select all
#include "wx/wx.h"
#include "wx/caret.h"
#include "wx/textctrl.h"
class MyApp : public wxApp
{
public:
virtual bool OnInit() wxOVERRIDE;
};
wxIMPLEMENT_APP(MyApp);
bool MyApp::OnInit()
{
wxFrame* myFrame = new wxFrame(nullptr, wxID_ANY, "Caret test", wxPoint(50, 50), wxSize(450, 340));
wxPanel* panel = new wxPanel(myFrame);
wxTextCtrl* ctrl = new wxTextCtrl(panel, wxID_ANY, "Empty text");
wxCaret* caret = new wxCaret(ctrl, 10, 18);
ctrl->SetCaret(caret);
caret->Move(1, 1);
caret->Show();
myFrame->Show();
return true;
}
How can I change the caret for a text control?