Skip to content

Commit

Permalink
Fixed the bug for #1895.
Browse files Browse the repository at this point in the history
  • Loading branch information
proneon267 committed Apr 25, 2023
1 parent 76713a9 commit fdb300a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions changes/1895.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ensured that the windows backend for `current_window` works properly.
4 changes: 3 additions & 1 deletion winforms/src/toga_winforms/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,9 @@ def set_main_window(self, window):
self.app_context.MainForm = window._impl.native

def get_current_window(self):
return WinForms.Form.ActiveForm._impl
for window in self.interface.windows:
if WinForms.Form.ActiveForm == window._impl.native:
return window._impl.native

def set_current_window(self, window):
window._impl.native.Activate()
Expand Down
3 changes: 3 additions & 0 deletions winforms/src/toga_winforms/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ def __init__(self, interface, title, position, size):

self.native = WinForms.Form()
self.native.interface = self.interface

self.native._impl = self

self.native.FormClosing += self.winforms_FormClosing

self.native.MinimizeBox = self.native.interface.minimizable
Expand Down

0 comments on commit fdb300a

Please sign in to comment.