diff options
author | B. Stack <bgstack15@gmail.com> | 2022-12-16 21:08:02 -0500 |
---|---|---|
committer | B. Stack <bgstack15@gmail.com> | 2022-12-16 21:08:02 -0500 |
commit | d35a4795f16e51f5773d00dce796f6948f82dae2 (patch) | |
tree | b37279f6f8b354407507cc1a0e44691d6c63ffe8 /wx+/no_flicker.h | |
parent | add upstream 11.28 (diff) | |
download | FreeFileSync-d35a4795f16e51f5773d00dce796f6948f82dae2.tar.gz FreeFileSync-d35a4795f16e51f5773d00dce796f6948f82dae2.tar.bz2 FreeFileSync-d35a4795f16e51f5773d00dce796f6948f82dae2.zip |
add upstream 11.2911.29
Diffstat (limited to 'wx+/no_flicker.h')
-rw-r--r-- | wx+/no_flicker.h | 45 |
1 files changed, 39 insertions, 6 deletions
diff --git a/wx+/no_flicker.h b/wx+/no_flicker.h index 7fa4ae23..185ee052 100644 --- a/wx+/no_flicker.h +++ b/wx+/no_flicker.h @@ -107,15 +107,48 @@ void setTextWithUrls(wxRichTextCtrl& richCtrl, const wxString& newText) break; } + //register only once! => use a global function pointer, so that Unbind() works correctly: + using LaunchUrlFun = void(*)(wxTextUrlEvent& event); + static const LaunchUrlFun launchUrl = [](wxTextUrlEvent& event) { wxLaunchDefaultBrowser(event.GetString()); }; + + [[maybe_unused]] const bool unbindOk1 = richCtrl.Unbind(wxEVT_TEXT_URL, launchUrl); if (std::any_of(blocks.begin(), blocks.end(), [](const auto& item) { return item.first == BlockType::url; })) + /**/richCtrl.Bind(wxEVT_TEXT_URL, launchUrl); + + struct UserData : public wxObject + { + explicit UserData(wxRichTextCtrl& rtc) : richCtrl(rtc) {} + wxRichTextCtrl& richCtrl; + }; + using KeyEventsFun = void(*)(wxKeyEvent& event); + static const KeyEventsFun onKeyEvents = [](wxKeyEvent& event) { - //register only once! => use a global function pointer, so that Unbind() works correctly: - using LaunchUrlFun = void(*)(wxTextUrlEvent& event); - static const LaunchUrlFun launchUrl = [](wxTextUrlEvent& event) { wxLaunchDefaultBrowser(event.GetString()); }; + wxRichTextCtrl& richCtrl = dynamic_cast<UserData*>(event.GetEventUserData())->richCtrl; //unclear if we can rely on event.GetEventObject() == richCtrl - [[maybe_unused]] const bool unbindOk = richCtrl.Unbind(wxEVT_TEXT_URL, launchUrl); - richCtrl.Bind(wxEVT_TEXT_URL, launchUrl); - } + //CTRL/SHIFT + INS is broken for wxRichTextCtrl on Windows/Linux (apparently never was a thing on macOS) + if (event.ControlDown()) + switch (event.GetKeyCode()) + { + case WXK_INSERT: + case WXK_NUMPAD_INSERT: + assert(richCtrl.CanCopy()); //except when no selection + richCtrl.Copy(); + return; + } + + if (event.ShiftDown()) + switch (event.GetKeyCode()) + { + case WXK_INSERT: + case WXK_NUMPAD_INSERT: + assert(richCtrl.CanPaste()); //except wxTE_READONLY + richCtrl.Paste(); + return; + } + event.Skip(); + }; + [[maybe_unused]] const bool unbindOk2 = richCtrl.Unbind(wxEVT_KEY_DOWN, onKeyEvents); + /**/ richCtrl. Bind(wxEVT_KEY_DOWN, onKeyEvents, wxID_ANY, wxID_ANY, new UserData(richCtrl) /*pass ownership*/); } } } |