-
- realesmedia
- Posts: 85
- Joined:
[C++] Check if mouse on the GUI
How to implement events OnMouseEnter and OnMouseLeave for all elements at once?
How can I check if mouse on the GUI or not?
How can I check if mouse on the GUI or not?
Last edited by realesmedia on 30 Jan 2017, 21:37, edited 1 time in total.
-
-
sfernandez
Site Admin
- Posts: 3222
- Joined:
Re: [C++] Check if mouse on the GUI
What do you mean for all elements at once?
If you want to be notified when an element on a subtree of elements is hovered with the mouse you just need to register to MouseEnter in the parent of that tree, because routed events traverse all elements in the tree.
To check if mouse is over any element of the GUI you can use VisualTreeHelper like this:
If you want to be notified when an element on a subtree of elements is hovered with the mouse you just need to register to MouseEnter in the parent of that tree, because routed events traverse all elements in the tree.
To check if mouse is over any element of the GUI you can use VisualTreeHelper like this:
Code: Select all
Visual* root = VisualTreeHelper::GetRoot(anyElement);
HitTestResult hit = VisualTreeHelper::HitTest(root, mousePos);
if (hit.visualHit != 0)
{
// Mouse is over a GUI element
}
else
{
// No GUI element is under the mouse
}
-
- realesmedia
- Posts: 85
- Joined:
Re: [C++] Check if mouse on the GUI
I have GUI but it's not only one who capture mouse click events. My scene capture it too and I want every click on GUI not be captured with scene.
-
- realesmedia
- Posts: 85
- Joined:
Re: [C++] Check if mouse on the GUI
And, yes, variant with VisualTreeHelper is an option. Thanks.
Re: [C++] Check if mouse on the GUI
Good to know you solved the issue!
Who is online
Users browsing this forum: Google [Bot] and 1 guest