2017-05-07 3 views
-2

사용자가 그것을 클릭 할 때 wxtextctrl 값을 지워야합니다. 나는 이것을 wxEVT_SET_FOCUS 핸들러에서 처리하지만, 비난 캐럿/커서는 숨어있다. 내가 뭘 잘못하고 있니? 다른 이벤트를 처리해야합니까?사용자가 wxTextCtrl을 클릭 할 때 깜박이는 커서를 표시하는 방법은 무엇입니까?

다음

MCVE : wxWidgets에의

# include "wx/wx.h" 

    class MyFrame : public wxFrame 
     { 
     public: 
      MyFrame(const wxString& title) : 
       wxFrame(NULL, -1, title, wxDefaultPosition, wxSize(200,150)) 
       { 
       wxBoxSizer* bSizer1 = new wxBoxSizer(wxVERTICAL); 
       m_textCtrl1 = new wxTextCtrl(this, wxID_ANY, wxT("sometext"), wxDefaultPosition, wxDefaultSize, 0); 
       m_textCtrl1->Bind(wxEVT_SET_FOCUS,[this](wxFocusEvent& e){ 
        m_textCtrl2->AppendText(m_textCtrl1->GetValue()+"\n"); 
        m_textCtrl1->SetValue(""); 
        m_textCtrl1->ShowPosition(0); 
        m_textCtrl1->ShowNativeCaret(true); 
        }); 
       bSizer1->Add(m_textCtrl1, 0, wxALL|wxEXPAND, 5); 
       bSizer1->Add(0, 0, 1, wxEXPAND, 5); 
       m_textCtrl2 = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE); 
       bSizer1->Add(m_textCtrl2, 0, wxALL|wxEXPAND, 5); 
       this->SetSizer(bSizer1); 
       this->Layout(); 
       } 
      ~MyFrame() {}; 

     protected: 
      wxTextCtrl* m_textCtrl1; 
      wxTextCtrl* m_textCtrl2; 
     }; 

    class MyApp : public wxApp 
     { 
     public: 
      virtual bool OnInit() wxOVERRIDE 
       { 
       MyFrame *frame = new MyFrame(wxT("MCVE")); 
       frame->Show(true); 
       return true; 
       }; 
     }; 

wxIMPLEMENT_APP(MyApp); 

버전 - 3.1.0, OS - Windows7의

당신은 네이티브 처리하기 위해서는 핸들러에서

e.Skip() 

를 호출 할 필요가

답변

4

효과가 나타납니다.

+0

그리고 ** ** [wxFocusEvent documentation] (http://docs.wxwidgets.org/3.1.0/classwx_focus_event.html)에서 ** ** 명시 적으로 설명되어 있습니다. –