Page 1 of 1

How to let the wxTextCtrl can select all by "ctrl+a&quo

Posted: Thu Jul 24, 2008 1:54 pm
by 00061205
How let wxTextCtrl can select all by "ctrl+a"

Posted: Thu Jul 24, 2008 7:38 pm
by SteveDowd
Check out wxKeyEvent:

http://docs.wxwidgets.org/stable/wx_wxk ... wxkeyevent

then handle the event by checking to see if event.CmdDown + "a" keyCode was pressed, then call wxTextCtrl::SetSelection(0, LastCharPos);

Posted: Fri Jul 25, 2008 1:21 am
by 00061205
SteveDowd wrote:Check out wxKeyEvent:

http://docs.wxwidgets.org/stable/wx_wxk ... wxkeyevent

then handle the event by checking to see if event.CmdDown + "a" keyCode was pressed, then call wxTextCtrl::SetSelection(0, LastCharPos);
Thanks, I'll try.

Posted: Sun Jul 27, 2008 2:59 am
by 00061205
I solved this problem by connect the keyevent to wxTextCtrl control.

Code: Select all

Step 1
TextCtrl1->Connect(ID_TEXTCTRL1,wxEVT_CHAR,(wxObjectEventFunction)&ctrlaFrame::OnChar,NULL,this);

Step 2
void ctrlaFrame::OnChar(wxKeyEvent& event)
{   //The keycode of "ctrl+a" is 1
    if(event.GetKeyCode()==1)
        TextCtrl1->SetSelection(-1,-1); //selecte all
    event.Skip();
}

Re: How to let the wxTextCtrl can select all by "ctrl+a&quo

Posted: Fri Jan 04, 2013 5:39 pm
by maximand
Thanks,

My suggestion:

Code: Select all

    if (wxGetKeyState(wxKeyCode('A')) && wxGetKeyState(WXK_CONTROL))
        tcSourceTxtCtrl_->SetSelection(-1, -1); //select all
    event.Skip();