Bug 4969 - Scrolling vs. OnMouseDown broken for ContainerControl
Summary: Scrolling vs. OnMouseDown broken for ContainerControl
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: 2012-05-09 12:27 UTC by Stephen McConnel
Modified: 2017-09-01 11:56 UTC (History)
1 user (show)

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


Attachments
test program to demonstrate the bug (6.29 KB, application/x-gzip)
2012-05-09 12:29 UTC, Stephen McConnel
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 4969 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 Stephen McConnel 2012-05-09 12:27:55 UTC
The handling for the WM_LBUTTONDOWN message by ContainerControl (which eventually invokes OnMouseDown) improperly scrolls at times.  In the current implementation, there is an internal variable named "auto_select_child" described in a comment as "an internal hack" that is used to prevent this behavior.  This internal hack is not good enough, because user defined controls may also need to prevent this behavior, which means that this behavior has bad side-effects.

I'm attaching a simple program (in the form of a MonoDevelop/Visual Studio 2010 project) to illustrate this problem.  After compiling the program, start it, then scroll the embedded control down until the label at the bottom is showing.  Then click the left button of the mouse near the label.  What should happen is that the read-only edit box at the top of the embedded control should be relocated to near the label at the bottom, with console output something like the following:

ScrollingControl.WndProc(WM_LBUTTONDOWN): [enter] ScrollPosition={X=0,Y=-545}
ScrollingControl.OnMouseDown(): [enter] ScrollPosition={X=0,Y=-545}, e.X=24, e.Y=213, m_textbox.Location={X=20,Y=-525}
ScrollingControl.OnMouseDown(): [leave] ScrollPosition={X=0,Y=-545}, m_textbox.Location={X=20,Y=213}
ScrollingControl.WndProc(WM_LBUTTONDOWN): [leave] ScrollPosition={X=0,Y=-545}

With Mono on Linux, the edit box is relocated, but near the top since the control has silently been scrolled back to show the edit box.  The console output looks something like this:

ScrollingControl.WndProc(WM_LBUTTONDOWN): [enter] ScrollPosition={X=0,Y=-616}
ScrollingControl.OnMouseDown(): [enter] ScrollPosition={X=0,Y=-20}, e.X=21, e.Y=209, m_textbox.Location={X=20,Y=0}
ScrollingControl.OnMouseDown(): [leave] ScrollPosition={X=0,Y=-20}, m_textbox.Location={X=20,Y=209}
ScrollingControl.WndProc(WM_LBUTTONDOWN): [leave] ScrollPosition={X=0,Y=-20}

Note that the scroll position has changed radically from entering the WndProc method to when it leaves, and the incorrect scroll position is already present when the OnMouseDown method is called.
Comment 1 Stephen McConnel 2012-05-09 12:29:12 UTC
Created attachment 1838 [details]
test program to demonstrate the bug