Displaying the mouse cursor in Noesis
Posted: 08 Apr 2023, 22:17
Hi.
I wanted to ask for some tips regarding cursor rendering. I couldn't really find that much information on it, so here's a couple questions:
1. Does Noesis have any built in cursor rendering functionality? I'm assuming that no - if we want to use cursors via .cur files we have to do that on our end and all Noesis does is send events via NoesisGUI.SetCursorCallback? And if we want to handle the cursor via Noesis we should treat it like any other control that we move via mouse events (see point 2)?
2. We are currently using a UserControl to display the cursor, settings it's position according to PreviewMouseMove and setting clicked/unclicked according to PreviewMouseLeftButtonDown/Up. The cursor is the bottom-most element in our visual tree.
ie.
Now this works properly for almost all cases - cursor is always rendered above everything else (since everything else is within MainMenuControl. The only problem so far is with popups. When we use Noesis' <Popup> control it is rendered above everything else, including the cursor. We tried some experimentation with ZIndex etc., but it doesn't seem to work (since the Popup doesn't have the same parent panel as Cursor).
Is there any solution to this problem, such as forcing the CursorControl to always render at the top (even above the Popups)? For now we just ignore the <Popup> control and use our own control which imitates the functionality, but we'd like to use the actual <Popup> to reduce the chance of problems appearing down the line. Another option would be to put a second CursorControl inside the popup, hide the first one and use the second one. But that seems really hacky to have to do for all popups. I'm looking for any tips as to what is the recommended way for handling the mouse cursor.
I wanted to ask for some tips regarding cursor rendering. I couldn't really find that much information on it, so here's a couple questions:
1. Does Noesis have any built in cursor rendering functionality? I'm assuming that no - if we want to use cursors via .cur files we have to do that on our end and all Noesis does is send events via NoesisGUI.SetCursorCallback? And if we want to handle the cursor via Noesis we should treat it like any other control that we move via mouse events (see point 2)?
2. We are currently using a UserControl to display the cursor, settings it's position according to PreviewMouseMove and setting clicked/unclicked according to PreviewMouseLeftButtonDown/Up. The cursor is the bottom-most element in our visual tree.
ie.
Code: Select all
<Window (...)>
<Canvas >
<Viewbox VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Height="{Binding ActualHeight, ElementName=window}" Width="{Binding ActualWidth, ElementName=window}">
<local:MainMenuControl ></local:MainMenuControl>
</Viewbox>
<common:CursorControl/>
</Canvas>
</Window>
Is there any solution to this problem, such as forcing the CursorControl to always render at the top (even above the Popups)? For now we just ignore the <Popup> control and use our own control which imitates the functionality, but we'd like to use the actual <Popup> to reduce the chance of problems appearing down the line. Another option would be to put a second CursorControl inside the popup, hide the first one and use the second one. But that seems really hacky to have to do for all popups. I'm looking for any tips as to what is the recommended way for handling the mouse cursor.