0

I'm trying to design a GUI touch screen application using wxWidgets(version 3.0.4). The touch screen is working fine. I need to use the on screen keyboard to populate a text box(wxTextCtrl).

I've done some searching and I dont find any setfocus or getfocus functions available for the wxTextCtrl. Neither can I find any event that tells that a cursor is placed in the text field so that I can invoke a onscreen keyboard.

Is there any library available or do I need to implement my own version of the keyboard?

Manoj
  • 23
  • 6
  • To my knowledge, there's no wx on screen keyboard. To your other questions, `wxTextCtrl` does have `SetFocus()` and [wxSetCursorEvent](https://docs.wxwidgets.org/trunk/classwx_set_cursor_event.html). – Ripi2 Aug 19 '19 at 17:05
  • @Mano, in our application we ha have a text control and a little button next to it. Whenever the user click this button or presses it another wxWindow pops up withe button that represent the keyboard layout. It works good on wxGTK. – Igor Aug 22 '19 at 02:45
  • Yeah that was supposed to be my plan B, however it would be preferable if the on screen keyboard pops up automatically. On second thoughts, I wanted to add the `EVT_LEFT_DCLICK` event in the `EVENT_TABLE` by modifying the wxwidgets source, `textctrl.cpp` file and miserably failed to do so. Any ideas on how it can be done would be greatly helpful – Manoj Aug 26 '19 at 12:59
  • After some research, I ended up using this eventhandler callback function `Connect(wxEVT_SET_FOCUS, wxFocusEventHandler(DoSomethingonOnFocus), NULL, this);` in which i'm using `system("xvkbd")` to invoke an onscreen keyboard. But the problem here is, there is no feedback from `xvkbd` until it is closed. That is all the characters entered are buffered until the keyboard is closed. Once the keyboard is closed, the characters are flushed out to the window/widget that's under focus. Any better ideas to accomplish this? – Manoj Sep 05 '19 at 09:58

1 Answers1

0

wxExecute function did the trick. I was able to successfully get the feedback in the wxwidget app from the key presses performed via the xvkbd. Sample code below:

this->main_frame->text_field->Connect(wxEVT_SET_FOCUS,wxFocusEventHandler(InvokeKeyboard), NULL, this);

void InvokeKeyboard(wxFocusEvent& event)
{
    event.Skip();
    system("killall xvkbd 1>/dev/null 2>/dev/null");
    wxExecute(wxT("xvkbd > /dev/null 2>/dev/null"), wxEXEC_ASYNC | wxEXEC_NODISABLE | wxEXEC_HIDE_CONSOLE );
}

You can refer here for the detailed documentation of wxExecute

Manoj
  • 23
  • 6