What's special about mouse capture and middle mouse button in WPF? -


When I call CaptureMouse () in response to mouse navigation, it will capture and then release mouse Will give

Hi?

I have tried to use preview events, setting handle = true, no matter what I do not understand mouse capture in WPF?

Here are some sample code that reproduce the problem.

  // TestListBox.cs using System.Diagnostics; Using System.Windows.Controls; Nom place local {public class} testlistbox: listbox {public testlist box () {mousedown = (_, e) = & gt; {Debug. Litlines ("+ mouseguard"); Debug.lightline ("Capture:" + CaptureMouse ()); Debug.WriteLine ("- MouseDown"); }; GotMouseCapture + = (_, e) = & gt; Debug.WriteLine ("GotMouseCapture"); LostMouseCapture + = (_, e) = & gt; Debug.WriteLine ("LostMouseCapture"); }}}  

Generating a default WPF app will use the test class for its main window:

  & lt; Window x: Class = "local.main window" xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns: x = "http://schemas.microsoft.com/winfx/ 2006 / xaml "xmlns: local =" CLR-namespace: local "title =" main window "height =" 350 "width =" 525 "& gt; & Lt; Local: TestListBox & gt; & Lt; ListBoxItem & gt; 1 & lt; / ListBoxItem & gt; & Lt; ListBoxItem & gt; 2 & lt; / ListBoxItem & gt; & Lt; ListBoxItem & gt; 3 & lt; / ListBoxItem & gt; & Lt; ListBoxItem & gt; 4 & lt; / ListBoxItem & gt; & Lt; / Local: TestListBox & gt; & Lt; / Window & gt;  

On clicking the button given below, I get this output:

  + MouseDown Capture LostMouse Capture Capture: True -MouseDown  

So I'm calling CaptureMouse, which in turn captures and then captures, still tells the truth that the capture was successfully achieved.

What's going on here? Is it possible that this is making some goofy with my Logitech mouse driver, trying to start 'ultrascroll' or something else?

This can be diagnosed by setting your debugger to break on UIElement. By viewing the ReleaseMouseCapture () method and call stack. If you do this, then you will know that this list is on Box on OnMouse which is causing the problem.

So what you have to do is override the override and do not call the base class, if the middle button is below:

  public class testlistbox: list box (secure Override Zero On-Mouse Meave (Mouse Even Eggs E) {If (Mouse. Muddlebutton! MousebootStat. Pressing) Base. OnMouseMove (E);}}  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -