ZanAlex
Topic Author
Posts: 66
Joined: 16 Jan 2015, 17:46

Debugging CaptureMouse and Focus

14 Sep 2015, 10:59

Hi,

I'm doing some refactoring in my code and I'm facing a weird problem. What I want to have is a drag'n drop behaviour. I've basically followed what you did in your sample.

I had a Control deriving from Border, put it into the UIElement tree by declaring it in the Xaml part. Its purpose was basically to move within its parent Canvas and display some representation, capture the mouse on drag and receive move and button up events. It worked great.

Now, rather than declaring it in Xaml, I'm adding it to the parent Canvas's children through C++. But as soon as I've done that, the CaptureMouse method does not work anymore, returning false.

Is there a way for me to check what actually failed? Do you have an idea?

Many thanks,
Alexandre.
Last edited by ZanAlex on 16 Sep 2015, 10:56, edited 1 time in total.
 
User avatar
sfernandez
Site Admin
Posts: 3188
Joined: 22 Dec 2011, 19:20

Re: Debugging CaptureMouse and Focus

16 Sep 2015, 01:41

Hi Alex,

Mouse capture can only return false in one of the following situations:

1.- If you try to capture a null element: mouse->Capture(0). But I think you are using the UIElement.CaptureMouse() method, so this is not the case.

2.- If you try to capture an element that is disabled (IsEnabled==False), or is not visible (Visibility!=Visible, or any ancestor is not visible too), or when is not visible for hit testing (IsHitTestVisible==False).

If none of the above is true, then Capture always return true.

Does this information shed some light?
 
ZanAlex
Topic Author
Posts: 66
Joined: 16 Jan 2015, 17:46

Re: Debugging CaptureMouse and Focus

16 Sep 2015, 08:38

Yes it does, thank you very much for your answer!

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], gjacob-RCG, Semrush [Bot] and 1 guest