In my GUI I have a wxSplitterWindow. The wxSplitterWindow contains 2 wxPanels: one has wxDataViewListCtrl and the other has wxRichTextCtrl.
I am programmatically updating the wxDataViewListCtrl with different data depending on some data base. I want the focus to be on the wxRichTextCtrl after every wxDataViewListCtrl update, e.g., I want the cursor to be blinking in the wxRichTextCtrl and ready for keyboard input (it simulates cmd.exe). I've tried things like `m_richText->SetFocus()` but it does not helps. Any ideas please?
wxrichtextctrl and disappearing cursor Topic is solved
Re: wxrichtextctrl and disappearing cursor
Hi,
1. What's your wx version?
2. What OS/toolkit?
3. Any special/non-standard option for building wx?
4. Are you using wxRichTextCtrl or wxTextCtrl with TE_RICH{2} style?
5. Can we see some code? Where did you put the SetFocus() call?
Thank you.
1. What's your wx version?
2. What OS/toolkit?
3. Any special/non-standard option for building wx?
4. Are you using wxRichTextCtrl or wxTextCtrl with TE_RICH{2} style?
5. Can we see some code? Where did you put the SetFocus() call?
Thank you.
Re: wxrichtextctrl and disappearing cursor
1. I use version 3.1.2.
2. Windows 10.
3. I've build static libs using the default options (I've changed nothing).
4. wxRichTextCtrl.
5. Here is some code:
2. Windows 10.
3. I've build static libs using the default options (I've changed nothing).
4. wxRichTextCtrl.
5. Here is some code:
Code: Select all
view_model->tree.subscribe([=](std::shared_ptr<std::vector<std::shared_ptr<Line>>> t)
{
// Do stuff here that updates the wxDataViewListCtrl with new data from a data base.
// Then do this to return the focus to the wxRichTextCtrl.
frame->m_richText->SetFocus(); // <-- This has no effect!
});
Re: wxrichtextctrl and disappearing cursor
Does the control properly get focus if you do it manually (click into the window)?
If yes, try calling SetFocus at a later time using wxEvtHandler::CallAfter():
https://docs.wxwidgets.org/trunk/classw ... 3b8a0c6a12
If yes, try calling SetFocus at a later time using wxEvtHandler::CallAfter():
https://docs.wxwidgets.org/trunk/classw ... 3b8a0c6a12
Use the source, Luke!
Re: wxrichtextctrl and disappearing cursor
Hi,
Also check if richtext sample works for you, i.e. the control can get focus and you can type in it after pressing the ALT+TAB.
Thank you.
Also check if richtext sample works for you, i.e. the control can get focus and you can type in it after pressing the ALT+TAB.
Thank you.
Re: wxrichtextctrl and disappearing cursor
The wxRichTextCtrl sample works perfectly, including ALT+TAB.ONEEYEMAN wrote:Hi,
Also check if richtext sample works for you, i.e. the control can get focus and you can type in it after pressing the ALT+TAB.
Thank you.
Re: wxrichtextctrl and disappearing cursor
That solved the issue. Thanks a a lot everyone.doublemax wrote:Does the control properly get focus if you do it manually (click into the window)?
If yes, try calling SetFocus at a later time using wxEvtHandler::CallAfter():
https://docs.wxwidgets.org/trunk/classw ... 3b8a0c6a12
Last edited by refaelsh on Sun Feb 17, 2019 8:37 pm, edited 1 time in total.
Re: wxrichtextctrl and disappearing cursor
doublemax, can you please explain to me why your solution works?
Re: wxrichtextctrl and disappearing cursor
It was just a guessrefaelsh wrote:doublemax, can you please explain to me why your solution works?
It all depends on when / from where you make the SetFocus() call. Usually it's from inside another event handler. And after your event handler is finished, there may be other events that are getting processed. And one of these could override your SetFocus() call by setting the focus to another control. By using CallAfter(), your code is only called after all other events have been processed.
But in order to find out who exactly overrides the focus, i'd need a working sample and analyze it.
Use the source, Luke!