mirror of
https://github.com/TomSchimansky/CustomTkinter.git
synced 2023-08-10 21:13:13 +03:00
added additional force_focus call for CTk and CTkToplevel on macOS to fix bug where window disappears when window is selected from Mission Control
This commit is contained in:
parent
5977dcbaeb
commit
362fcbaf13
@ -67,9 +67,15 @@ class CTk(tkinter.Tk):
|
||||
self._windows_set_titlebar_color("light")
|
||||
|
||||
self.bind('<Configure>', self._update_dimensions_event)
|
||||
self.bind('<FocusIn>', 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
|
||||
|
@ -63,6 +63,12 @@ class CTkToplevel(tkinter.Toplevel):
|
||||
self._windows_set_titlebar_color("light")
|
||||
|
||||
self.bind('<Configure>', self._update_dimensions_event)
|
||||
self.bind('<FocusIn>', 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
|
||||
|
Loading…
Reference in New Issue
Block a user