Multiple wxStyledTextCtrl and shortcut handling

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2409
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

Multiple wxStyledTextCtrl and shortcut handling

Post by evstevemd »

I have this problem that I cannot sort out right now. I have three wxSTC under three different panels and I switch extensively between them. I want to be able to use shortcut (Ctrl+C/X/V). However, regadless of which STC have the focus, the first STC handles the event.

Here is an example if the above explanations aren't enough. Let say STCs are s1, s2 and s2.
- If focus is with s1 Ctrl+C copies selected text from s1 - Good
- move cursor to s2 and do Ctr+C, it copies selection from s1 - Bad
- move cursor to s3 and do Ctr+C, it copies selection from s1 - Bad

Is there a way to bind shortcurts to focused wxSTC without going thru handling events? wxTextCtrl seems to work just fine and effortlessly. I expected wxSTC to follow the same suit.

TIA
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Multiple wxStyledTextCtrl and shortcut handling

Post by doublemax »

Can you build a small sample with only two wxSTC side-by-side and check if it happens there, too?
Use the source, Luke!
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2409
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

Re: Multiple wxStyledTextCtrl and shortcut handling

Post by evstevemd »

doublemax wrote:Can you build a small sample with only two wxSTC side-by-side and check if it happens there, too?
I didn't thought of this. Let me test that!
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2409
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

Re: Multiple wxStyledTextCtrl and shortcut handling

Post by evstevemd »

So I tested with sample the scenario is the same.
Just apply the patch below and then select text on an open editor. Go to menu (Window->Minima Editor) and it will open two more editors in a dialog.
Try select text in any of the two and do Ctrl+X and see that it cuts text from first editor not the current.

I'm not sure if that is the expected behavior or I just found a prize bug!

Code: Select all

diff --git a/samples/stc/stctest.cpp b/samples/stc/stctest.cpp
index 34ab8a8..52fb80b 100644
--- a/samples/stc/stctest.cpp
+++ b/samples/stc/stctest.cpp
@@ -824,9 +824,11 @@ public:
     MinimalEditorFrame() : wxFrame(NULL, wxID_ANY, _("Minimal Editor"))
     {
         MinimalEditor* editor = new MinimalEditor(this);
+        MinimalEditor* editor2 = new MinimalEditor(this);
         editor->SetFont(wxSystemSettings::GetFont(wxSYS_ANSI_FIXED_FONT));
         wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
         sizer->Add(editor, 1, wxEXPAND);
+        sizer->Add(editor2, 1, wxEXPAND);
         SetSizer(sizer);
         editor->SetText(
            "<xml>\n"
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Multiple wxStyledTextCtrl and shortcut handling

Post by doublemax »

I haven't tested it myself yet, but this smells like a bug in wxSTC.
Use the source, Luke!
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2409
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

Re: Multiple wxStyledTextCtrl and shortcut handling

Post by evstevemd »

doublemax wrote:I haven't tested it myself yet, but this smells like a bug in wxSTC.
I will file a bug report for futher followup
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2409
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

Re: Multiple wxStyledTextCtrl and shortcut handling

Post by evstevemd »

Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Post Reply