Bug 15848 - Form.Deactivate event is not raised when another form is explicitly activated
Summary: Form.Deactivate event is not raised when another form is explicitly activated
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: Windows.Forms ()
Version: 2.10.x
Hardware: PC Linux
: Lowest normal
Target Milestone: Community
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-10-31 12:14 UTC by John Thomson
Modified: 2017-09-01 11:56 UTC (History)
1 user (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Complete solution showing the problem (8.11 KB, application/x-gzip)
2013-10-31 12:14 UTC, John Thomson
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 15848 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
NEW

Description John Thomson 2013-10-31 12:14:10 UTC
Created attachment 5292 [details]
Complete solution showing the problem

Mono apparently fails to send the Deactivate event to a Form when another form is activated by calling its Activate() method.

The attached program demonstrates the problem. When run on Windows (you might need to rename the three .resources files to their original .resx names to build with VS), click "button1" on the original form; the popup form appears. Click "button1" in the popup form, and a message box appears. On Windows, the popup form is hidden; on Mono, it stays around.

The reason it should get hidden is because of code in its constructor (PopupForm.PopupForm):

   this.Deactivate += (sender, args) => this.Hide();

The action (this.Hide()) executes on Windows when _parentWindow.Activate() is called in PopupForm.button1_Click.

On Mono this action does not execute.

The fact that a third window (the message box) is activated immediately afterwards may be something to do with the problem.

Curiously, the event is raised properly (on both platforms) if the user manually clicks on another window. Somehow the explicit call to Activate() does not raise it.

(We are using our own build of Mono 2.10, with various bugs fixed. I haven't tried this with an unmodified 2.10, but I don't think we've changed anything relevant.)
Comment 1 Miguel de Icaza [MSFT] 2014-02-12 17:27:07 UTC
Setting priority to lowest, since Windows.Forms is no longer being developed actively.