diff --git a/customtkinter/windows/ctk_tk.py b/customtkinter/windows/ctk_tk.py index 98777a2..599f18f 100644 --- a/customtkinter/windows/ctk_tk.py +++ b/customtkinter/windows/ctk_tk.py @@ -67,9 +67,15 @@ class CTk(tkinter.Tk): self._windows_set_titlebar_color("light") self.bind('', self._update_dimensions_event) + self.bind('', self._focus_in_event) self._block_update_dimensions_event = False + def _focus_in_event(self, event): + # sometimes window looses focus on macOS if window is selected from Mission Control, so focus has to be forced again + if sys.platform == "darwin": + self.focus_force() + def _update_dimensions_event(self, event=None): if not self._block_update_dimensions_event: detected_width = self.winfo_width() # detect current window size diff --git a/customtkinter/windows/ctk_toplevel.py b/customtkinter/windows/ctk_toplevel.py index fdda6c6..54bab28 100644 --- a/customtkinter/windows/ctk_toplevel.py +++ b/customtkinter/windows/ctk_toplevel.py @@ -63,6 +63,12 @@ class CTkToplevel(tkinter.Toplevel): self._windows_set_titlebar_color("light") self.bind('', self._update_dimensions_event) + self.bind('', self._focus_in_event) + + def _focus_in_event(self, event): + # sometimes window looses focus on macOS if window is selected from Mission Control, so focus has to be forced again + if sys.platform == "darwin": + self.focus_force() def _update_dimensions_event(self, event=None): detected_width = self.winfo_width() # detect current window size