Emulating a key press in wxTextCtrl

View: New views
1 Messages — Rating Filter:   Alert me  

Emulating a key press in wxTextCtrl

by Tamer El Nashar-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

os: win xp pro sp3
wx: cvs
compiler: vc7

Hello,

I am trying to emulate a left and right key press in a wxTextCtrl. As i am handling the left and right key presses globally in my frame, i have the following code:

void CVibeStationFrame::OnLeftArrow(wxCommandEvent& event)
{
    wxTextCtrl* textCtrl = wxDynamicCast(FindFocus(), wxTextCtrl);

    if (textCtrl) // If focus is on a text control
    {
        wxKeyEvent event(wxEVT_KEY_DOWN);

        event.m_keyCode = WXK_LEFT;

        event.m_uniChar = WXK_LEFT;

        event.m_rawCode = WXK_LEFT;

        wxPostEvent(textCtrl, event);

        //textCtrl->GetEventHandler()->ProcessEvent(event);

        //textCtrl->EmulateKeyPress(event);
    }   
    else // Otherwise update play start time


As shown above i tried ProcessEvent and EmulateKeyPress and none of them worked. What is the right way to post a key event to a text control?

--~--~---------~--~----~------------~-------~--~----~
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+unsubscribe@...
or visit http://groups.google.com/group/wx-users
-~----------~----~----~----~------~----~------~--~---