All mouse interaction is offset
Hello,
All of our interactive objects are offset by a few pixels like so:
Not just buttons, also input fields etc.
Inspector highlight doesn't seem to show why, when mouse is right on top few pixels of the button the entire panel is selected as if cursor is way off the button.
I'd like to ask for some pointers on how to debug something like this?
I'm going through our button styles and such to see if offsets make a difference, but I don't see how we could make visual boundary disjointed from interaction boundary.
Maybe animations can do this?
edit: is there an easy way to attach a marker to where Noesis thinks current mouse is? Maybe mouse being sent to Noesis is disjointed from actual mouse position?
All of our interactive objects are offset by a few pixels like so:
Not just buttons, also input fields etc.
Inspector highlight doesn't seem to show why, when mouse is right on top few pixels of the button the entire panel is selected as if cursor is way off the button.
I'd like to ask for some pointers on how to debug something like this?
I'm going through our button styles and such to see if offsets make a difference, but I don't see how we could make visual boundary disjointed from interaction boundary.
Maybe animations can do this?
edit: is there an easy way to attach a marker to where Noesis thinks current mouse is? Maybe mouse being sent to Noesis is disjointed from actual mouse position?
-
sfernandez
Site Admin
- Posts: 2991
- Joined:
Re: All mouse interaction is offset
If all the UI elements are affected by this offset I would say it is a problem with the integration layer (mouse coordinates injected into the IView are not correct). Styles or animations won't be the cause for this.
You can draw a cross hair in your main window that is moved with the mouse to detect that:
To update the cross hair position you can hook to PreviewMouseMove in your root element:
Could you try that and let us know what you find?
You can draw a cross hair in your main window that is moved with the mouse to detect that:
Code: Select all
<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Canvas Background="Transparent">
<Path x:Name="MouseCursor" Data="M0,10L20,10M10,0L10,20" Stroke="Yellow" Stretch="None" Margin="-10,-10,10,10"/>
</Canvas>
</Grid>
Code: Select all
MainWindow::MainWindow()
{
PreviewMouseMove() += [this](BaseComponent*, const MouseEventArgs& e)
{
UIElement* mouseCursor = FindName<UIElement>("MouseCursor");
Canvas::SetLeft(mouseCursor, e.position.x);
Canvas::SetTop(mouseCursor, e.position.y);
};
}
Re: All mouse interaction is offset
Hi!
Thank you for the debugging info, super helpful!
Here's what I found so far:
- (green) all capture areas are offset by same relative amount from top middle-ish (red) of the screen.
- (yellow +) the raw noesis mouse pointer and actual interaction area don't match. Also very easily spoofed by resizing the window, where
- (purple) Interaction area is in-between raw mouse and windows mouse pointer (maybe 40-60% split?) . green vs yellow not quite to scale, purple shows better.
I'll keep poking around raw mouse updates ..
- windows pointer to noesis raw mouse difference can exaggerated by resizing the window, however green capture area changes only a little.
Thank you for the debugging info, super helpful!
Here's what I found so far:
- (green) all capture areas are offset by same relative amount from top middle-ish (red) of the screen.
- (yellow +) the raw noesis mouse pointer and actual interaction area don't match. Also very easily spoofed by resizing the window, where
- (purple) Interaction area is in-between raw mouse and windows mouse pointer (maybe 40-60% split?) . green vs yellow not quite to scale, purple shows better.
I'll keep poking around raw mouse updates ..
- windows pointer to noesis raw mouse difference can exaggerated by resizing the window, however green capture area changes only a little.
-
sfernandez
Site Admin
- Posts: 2991
- Joined:
Re: All mouse interaction is offset
Some questions...
Are you on Noesis 3.0, right?
Are you using our application framework for the windowing system or your own?
Have you set a scale in Windows 10 Display settings?
Are you setting any projection matrix (SetProjectionMatrix) in the IView?
One thing that comes to my mind is that you are possibly calling IView::SetSize with incorrect client rect when your system window is resized, could you please check that?
Are you on Noesis 3.0, right?
Are you using our application framework for the windowing system or your own?
Have you set a scale in Windows 10 Display settings?
Are you setting any projection matrix (SetProjectionMatrix) in the IView?
One thing that comes to my mind is that you are possibly calling IView::SetSize with incorrect client rect when your system window is resized, could you please check that?
Re: All mouse interaction is offset
Hello,
1) We're on Noesis 3.1.0-9989
2) Yes, we're using application framework.
3) No scale in windows 10.
4) No instance of SetProjectionMatrix use.
5) Ae are using SetSize like this:
SetSize can be called in several other spots that but currently only the above case gets triggered.
Get trigged as window appears. Maybe we're missing a SetSize / AdjustWindowSize earlier in init?
1) We're on Noesis 3.1.0-9989
2) Yes, we're using application framework.
3) No scale in windows 10.
4) No instance of SetProjectionMatrix use.
5) Ae are using SetSize like this:
Code: Select all
display->SizeChanged() += [view, ctx](NoesisApp::Display*, uint32_t width, uint32_t height) {
view->SetSize(width, height); // debugger values: 1920x1029 , but actual window size: 1906x1022
ctx->Resize();
};
Get trigged as window appears. Maybe we're missing a SetSize / AdjustWindowSize earlier in init?
Re: All mouse interaction is offset
Ha!
Thank you, your samples have the correct code to fix our mouse cursor bounding box issue!
FYI though, the crosshair still acts weird and doesn't quite follow the mouse pointer.
Edit: I'd also like to ask if you have idea why function params would produce different results from display-GetClient.. ? Does display do something specials / scaling / window with border vs borderless calculations?
Thank you, your samples have the correct code to fix our mouse cursor bounding box issue!
Code: Select all
display->SizeChanged() += [view, ctx](NoesisApp::Display* display, uint32_t, uint32_t)
{
view->SetSize(display->GetClientWidth(), display->GetClientHeight());
ctx->Resize();
};
Edit: I'd also like to ask if you have idea why function params would produce different results from display-GetClient.. ? Does display do something specials / scaling / window with border vs borderless calculations?
-
sfernandez
Site Admin
- Posts: 2991
- Joined:
Re: All mouse interaction is offset
Glad it finally works.
This can happen if the Canvas where the crosshair is placed doesn't fill the entire window. Could that be the case? To make sure you use the correct coordinates you can transform them to the canvas local space:FYI though, the crosshair still acts weird and doesn't quite follow the mouse pointer.
Code: Select all
MainWindow::MainWindow()
{
PreviewMouseMove() += [this](BaseComponent*, const MouseEventArgs& e)
{
Canvas* mouseCanvas = FindName<Canvas>("MouseCanvas");
UIElement* mouseCursor = FindName<UIElement>("MouseCursor");
Point p = mouseCanvas->PointFromScreen(e.position);
Canvas::SetLeft(mouseCursor, p.x);
Canvas::SetTop(mouseCursor, p.y);
};
}
The width and height reported by Display's SizeChanged event include window's title bar and borders, but the View requires the client area of the window only, the size of the render surface. That is why you should call view->SetSize(display->GetClientWidth(), display->GetClientHeight()).I'd also like to ask if you have idea why function params would produce different results from display-GetClient.. ? Does display do something specials / scaling / window with border vs borderless calculations?
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 68 guests