Re: Handling wxKeyEvent in another wxStyledTextCtrl

Eran Ifrah <[email protected]>
Newsgroups gmane.comp.lib.wxwindows.general
Message-ID <[email protected]>
To answer my own question (replying in case someone else will need this...):

In the first wxSTC (where the key event is unwanted), I added this code:

        m_stc_bottom->CallAfter(&InputCtrl::SetFocus);
        m_stc_bottom ->CallAfter(&InputCtrl ::SimulateKeyEvent, event);

And in the bottom control, I added this code:

    wxUIActionSimulator sim;
    sim.KeyDown(event.GetKeyCode(), event.GetModifiers());

And this seems to be working (at least on Windows, need to test this on 
macOS / Linux...)

On Thursday, July 27, 2023 at 10:36:13 PM UTC+3 Eran Ifrah wrote:

> Hello,
>
> I have a small question:
> I have a custom control which consists of 2 wxStyledTextCtrl (laid out 
> vertically)
>
> My end goal: when a user types a character inside the top 
> wxStyledTextCtrl, I want it to be processed by the bottom wxStyledTextCtrl.
>
> e.g. 
>
> If a user hit the `a` character while the focus is in the top 
> wxStyledTextCtrl, I want:
>
> - The focus is shifted to the bottom wxStyledTextCtrl
> - The char `a` is printed in the bottom wxStyledTextCtrl
>
> Can this be achieved?
> (I tried various solutions, none seemed to work. For example: bind 
> wxEVT_CHAR_HOOK and in the top wxSTC and then setting the focus to the 
> bottom followed by calling `ProcessEvent` in the lower wxSTC
>
> Any ideas what can be done?
>
> Thanks,
> Eran
>
>

-- 
Please read https://www.wxwidgets.org/support/mlhowto.htm before posting.
--- 
You received this message because you are subscribed to the Google Groups "wx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/wx-users/b51f9ac2-ca29-4ebd-90bc-8a3338f1b3acn%40googlegroups.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.