Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It seemed to be something to do with the mouse capture!?</p> <p>The normal sequence of events during a drag goes something like this...</p> <ol> <li>The <code>PreviewMouseLeftButtonDown</code> handler gets called and <code>ListBox.IsMouseCaptureWithin</code> is false.</li> <li>The <code>PreviewMouseMove</code> handler gets called. By this time <code>ListBox.IsMouseCaptureWithin</code> is true.</li> <li>During the <code>PreviewMouseMove</code> handler <code>DragDrop.DoDragDrop</code> gets called and sometime during this the mouse capture is released from the ListBox.</li> </ol> <p>But, what seems to happening for a drag started when the context menu is open is...</p> <ol> <li>The <code>PreviewMouseLeftButtonDown</code> handler gets called and <code>ListBox.IsMouseCaptureWithin</code> is false.</li> <li>The <code>PreviewMouseMove</code> handler gets called. But this time <code>ListBox.IsMouseCaptureWithin</code> is still false.</li> <li>Sometime after the end of the <code>PreviewMouseMove</code> handler the ListBox then gets the mouse capture (<code>ListBox.IsMouseCaptureWithin</code> becomes true)</li> </ol> <p>The result of this is that after the drag, the ListBox still has the mouse capture so any clicks on the button to open the context menu are actually going to the listbox not the button.</p> <p>Adding the following code to the start of the <code>PreviewMouseLeftButtonDown</code> handler seems to help by swallowing up the click that closes that context menu rather than trying to start a drag from it...</p> <pre><code>if (!contextMenuCloseComplete) { sourceElement.CaptureMouse(); return; } </code></pre> <p>...with the <code>contextMenuCloseComplete</code> bool getting set in handlers for the context menu's <code>Closed</code> and <code>Opened</code> events.</p> <p>Does that make sense? Does anyone understand where this mouse capture behaviour is coming from?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload