Skip to content

Commit a63012e

Browse files
committed
fix: 'z' key triggers zoom instead of typing in text fields (#10684)
On Windows, pressing 'z' while a custom TextInput widget was focused triggered the canvas 'zoom to fit' shortcut instead of inserting the character. is_text_entry_focused() only walked up the parent chain; on Windows focus sometimes lands on the outer StaticBox container rather than the inner wxTextCtrl. Extend the check to also scan direct children of the focused window. Closes #10684
1 parent 2263815 commit a63012e

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

src/slic3r/GUI/MainFrame.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,20 @@ wxDEFINE_EVENT(EVT_LOAD_PRINTER_URL, wxCommandEvent);
100100

101101
static bool is_text_entry_focused()
102102
{
103-
for (wxWindow *window = wxWindow::FindFocus(); window != nullptr; window = window->GetParent())
104-
if (dynamic_cast<wxTextEntry *>(window) != nullptr)
103+
wxWindow *focused = wxWindow::FindFocus();
104+
// Walk up the parent chain — covers the common case where a native text
105+
// control (wxTextCtrl) or a composite widget's inner text ctrl has focus.
106+
for (wxWindow *w = focused; w != nullptr; w = w->GetParent())
107+
if (dynamic_cast<wxTextEntry *>(w) != nullptr)
105108
return true;
106-
109+
// Also check direct children of the focused window: on some platforms
110+
// (e.g. Windows with custom TextInput panels) focus lands on the outer
111+
// container while the inner wxTextCtrl is a direct child.
112+
if (focused) {
113+
for (wxWindowList::Node *node = focused->GetChildren().GetFirst(); node; node = node->GetNext())
114+
if (dynamic_cast<wxTextEntry *>(node->GetData()) != nullptr)
115+
return true;
116+
}
107117
return false;
108118
}
109119

0 commit comments

Comments
 (0)