mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-18 21:20:57 +00:00
Let Global shortcuts run while typing, except keys that edit text (#16558)
#16505 skipped every Global shortcut while ImGui had the keyboard, so Ctrl+S, Ctrl+R and the others did nothing while the cursor was in the text tool's box. Skip only the chords that edit text, and only while a text field (a wx text entry, a spin control, a web view, or an active ImGui InputText) has the focus. Skip every Global shortcut while an ImGui modal is open on the focused canvas. KeyChord::edits_text() defines the text-editing chords. The Global page of the shortcuts dialog no longer says these shortcuts apply while typing.
This commit is contained in:
1 parent
c1fb801ff3
commit
0f59cd5d05
11 files changed
+284
-25
No files matched your search
@@ -126,6 +126,55 @@ TEST_CASE("Only modified or non-printable chords qualify as menu accelerators",
|
||||
CHECK(registry.accelerator(Shortcut::KeyboardShortcuts).empty());
|
||||
}
|
||||
|
||||
TEST_CASE("Typing, caret, deletion and clipboard chords edit text", "[Shortcuts]")
|
||||
{
|
||||
CHECK(KeyChord{ 'A' }.edits_text());
|
||||
CHECK(KeyChord{ 'A', wxMOD_SHIFT }.edits_text());
|
||||
CHECK(KeyChord{ WXK_SPACE }.edits_text());
|
||||
CHECK(KeyChord{ WXK_BACK }.edits_text());
|
||||
CHECK(KeyChord{ WXK_DELETE }.edits_text());
|
||||
CHECK(KeyChord{ WXK_BACK, wxMOD_CONTROL }.edits_text());
|
||||
CHECK(KeyChord{ WXK_LEFT, wxMOD_SHIFT }.edits_text());
|
||||
CHECK(KeyChord{ WXK_RIGHT, wxMOD_CONTROL | wxMOD_SHIFT }.edits_text());
|
||||
CHECK(KeyChord{ WXK_HOME }.edits_text());
|
||||
CHECK(KeyChord{ WXK_END, wxMOD_CONTROL }.edits_text());
|
||||
CHECK(KeyChord{ WXK_DELETE, wxMOD_SHIFT }.edits_text());
|
||||
CHECK(KeyChord{ WXK_INSERT }.edits_text());
|
||||
CHECK(KeyChord{ WXK_INSERT, wxMOD_SHIFT }.edits_text());
|
||||
CHECK(KeyChord{ WXK_INSERT, wxMOD_CONTROL }.edits_text());
|
||||
CHECK(KeyChord{ WXK_PAGEUP, wxMOD_SHIFT }.edits_text());
|
||||
CHECK(KeyChord{ WXK_RETURN }.edits_text());
|
||||
CHECK(KeyChord{ WXK_TAB, wxMOD_SHIFT }.edits_text());
|
||||
CHECK(KeyChord{ WXK_ESCAPE }.edits_text());
|
||||
CHECK(KeyChord{ WXK_PAGEDOWN }.edits_text());
|
||||
for (int key : { 'A', 'C', 'V', 'X', 'Y', 'Z' })
|
||||
CHECK(KeyChord{ key, wxMOD_CONTROL }.edits_text());
|
||||
CHECK(KeyChord{ 'Z', wxMOD_CONTROL | wxMOD_SHIFT }.edits_text());
|
||||
|
||||
CHECK_FALSE(KeyChord{ WXK_TAB, wxMOD_CONTROL }.edits_text());
|
||||
CHECK_FALSE(KeyChord{ WXK_RETURN, wxMOD_CONTROL }.edits_text());
|
||||
CHECK_FALSE(KeyChord{ WXK_PAGEDOWN, wxMOD_CONTROL }.edits_text());
|
||||
CHECK_FALSE(KeyChord{ WXK_ESCAPE, wxMOD_CONTROL }.edits_text());
|
||||
CHECK_FALSE(KeyChord{ 'S', wxMOD_CONTROL }.edits_text());
|
||||
CHECK_FALSE(KeyChord{ 'S', wxMOD_CONTROL | wxMOD_SHIFT }.edits_text());
|
||||
CHECK_FALSE(KeyChord{ '0', wxMOD_CONTROL }.edits_text());
|
||||
CHECK_FALSE(KeyChord{ WXK_F5 }.edits_text());
|
||||
CHECK_FALSE(KeyChord{}.edits_text());
|
||||
#ifdef __APPLE__
|
||||
CHECK(KeyChord{ 'E', wxMOD_ALT }.edits_text());
|
||||
CHECK(KeyChord{ 'K', wxMOD_RAW_CONTROL }.edits_text());
|
||||
CHECK(KeyChord{ WXK_LEFT, wxMOD_ALT }.edits_text());
|
||||
CHECK(KeyChord{ WXK_LEFT, wxMOD_CONTROL }.edits_text());
|
||||
CHECK_FALSE(KeyChord{ WXK_LEFT, wxMOD_RAW_CONTROL }.edits_text());
|
||||
CHECK_FALSE(KeyChord{ 'E', wxMOD_CONTROL | wxMOD_ALT }.edits_text());
|
||||
#else
|
||||
CHECK(KeyChord{ 'Q', wxMOD_CONTROL | wxMOD_ALT }.edits_text());
|
||||
CHECK_FALSE(KeyChord{ 'E', wxMOD_ALT }.edits_text());
|
||||
CHECK_FALSE(KeyChord{ WXK_LEFT, wxMOD_ALT }.edits_text());
|
||||
CHECK_FALSE(KeyChord{ WXK_LEFT, wxMOD_CONTROL | wxMOD_ALT }.edits_text());
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_CASE("Chords the desktop keeps for itself are recognized", "[Shortcuts]")
|
||||
{
|
||||
#ifdef _WIN32
|
||||
@@ -186,6 +235,21 @@ TEST_CASE("Default bindings never collide inside a context", "[Shortcuts]")
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("No default Global binding except the Speed Dial's Space edits text", "[Shortcuts]")
|
||||
{
|
||||
ShortcutRegistry registry;
|
||||
size_t checked = 0;
|
||||
for (size_t i = 0; i < size_t(Shortcut::Count); ++i) {
|
||||
const ShortcutInfo& info = shortcut_info(Shortcut(i));
|
||||
if ((info.contexts & context_bit(ShortcutContext::Global)) == 0 || info.id == Shortcut::SpeedDial)
|
||||
continue;
|
||||
CAPTURE(info.key);
|
||||
CHECK_FALSE(registry.binding(info.id).edits_text());
|
||||
++checked;
|
||||
}
|
||||
CHECK(checked > 0);
|
||||
}
|
||||
|
||||
TEST_CASE("Shift and Ctrl variants of stepping shortcuts are left unbound", "[Shortcuts]")
|
||||
{
|
||||
ShortcutRegistry registry;
|
||||
|
||||
Reference in new issue
Block a user