C++ how to detect if mouse is over IView? (Layered views)
Due problems with Noesis with glfw windows (under windows 10) I decided my application will have one window. I created second IView and render it inside main window.
How can I detect mouse under IView to attach mouse and keyboard input? Now when some control is behind second IView, it interact with first IView.
How can I detect mouse under IView to attach mouse and keyboard input? Now when some control is behind second IView, it interact with first IView.
Re: C++ how to detect if mouse is over IView? (Layered views)
IView is operating system agnostic. It means you are in charge of sending the events whenever they are needed. If you are rendering to the same window, then you know the sizes given to each view rigth? it should be easy to know if the mouse is on top of a view or not. You could also use the HitTesting functionality provided by VisualTreeHelper.h.
By the way, we don't recommend using more than one view for the same window. We optimized this scenario a lot in 2.X but better if you can avoid it.
By the way, we don't recommend using more than one view for the same window. We optimized this scenario a lot in 2.X but better if you can avoid it.
Re: C++ how to detect if mouse is over IView? (Layered views)
And what is better to create new "window" inside window? This "window" I mean Grid which will be rendered before main Grid.
-
-
sfernandez
Site Admin
- Posts: 2058
- Joined:
Re: C++ how to detect if mouse is over IView? (Layered views)
If you want to add several Window/Dialogs to the same IView define a root panel (for example a Grid) that can serve as container (desktop). Then you can add all the windows you want to that root panel and use Panel.ZIndex property to manage the z order.
For example, you can have the following xaml loaded and initially set as content of the IView:
Then whenever you want to add a new window:
And when you need to change the z order of a window:
For example, you can have the following xaml loaded and initially set as content of the IView:
Code: Select all
<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid x:Name="WindowContainer"/>
...
</Grid>
Code: Select all
auto window = Noesis::GUI::LoadXaml<Noesis::FrameworkElement>("GUI/Dialogs/SettingsWindow.xaml");
auto windowContainer = mXamlView->GetContent()->FindName<Noesis::Grid>("WindowContainer");
windowContainer->GetChildren()->Add(window.GetPtr());
Code: Select all
void MoveWindowToForeground(Noesis::FrameworkElement* window)
{
mTopWindowZ++;
Noesis::Panel::SetZIndex(window, mTopWindowZ);
}
Re: C++ how to detect if mouse is over IView? (Layered views)
Thanks sfernandez, it is looks like working except Z-Index:
second Grid is still behind main grid, whatever value I add in to mTopWindowZ. But maybe it is windows 10 and opengl problem. Another problem is, when second grid is created, GUI rendering have problems, it looks like it render twice or more and it is blended and color is additive and it start flickering when window is resized. I can't test it under windows 7 now.
Code: Select all
void MoveWindowToForeground(Noesis::FrameworkElement* window)
{
mTopWindowZ++;
Noesis::Panel::SetZIndex(window, mTopWindowZ);
}
-
-
sfernandez
Site Admin
- Posts: 2058
- Joined:
Re: C++ how to detect if mouse is over IView? (Layered views)
From what you are describing it seems like you are not clearing the surface each frame.
If for example you are under a GL environment the minimum steps to perform each frame should be:
If for example you are under a GL environment the minimum steps to perform each frame should be:
Code: Select all
mView->Update(currentTimeInSeconds);
Noesis::IRenderer* renderer = mView->GetRenderer();
renderer->UpdateRenderTree();
if (renderer->NeedsOffscreen())
{
renderer->RenderOffscreen();
}
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glViewport(0, 0, width, height);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
renderer->Render();
Re: C++ how to detect if mouse is over IView? (Layered views)
I apologize, it was ok (Z Index). Porblem is, it not show full grid (choose window), only part of this grid without textboxes and buttons.
Re: C++ how to detect if mouse is over IView? (Layered views)
I discover, the buttons and other "window" elements, they there are, but rendered grid is only limited size.
When I add Height="500" for example, Grid is not changed to this size. I implement move window, and if grid is moved with Height="500", is not moved, but only grid inside this grid. I create video for this problem and post it here, when I will have time.
Finally, problem described above is due my mainGrid has rows,if I add this code in WindowContainer Grid is displayed in row 1 insitead row 0. And then grid inside WindowContainer grid is displayed full. Now question is, how to display grid in full window without add grid in to row or column?
When I add Height="500" for example, Grid is not changed to this size. I implement move window, and if grid is moved with Height="500", is not moved, but only grid inside this grid. I create video for this problem and post it here, when I will have time.
Finally, problem described above is due my mainGrid has rows,
Code: Select all
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Content="TEXT" FontSize="16" FontWeight="Bold" Foreground="White"/>
<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// GRID RESOURCES -->
<Grid.Resources>
<DataModel x:Name="dataModel" />
</Grid.Resources>
<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
<Grid x:Name="WindowContainer" >
</Grid>
Code: Select all
Grid.Row="1"
Who is online
Users browsing this forum: Google [Bot] and 0 guests