最近处理avalonia 展示3D模型的时候,想添加鼠标右键旋转功能,遇到鼠标事件无法响应。添加了IsHitTestVisible="True" 仍然没有作用,解决方式,实现ICustomHitTest接口,代码如下。
internal class GLESControl : OpenGlControlBase, ICustomHitTest
{
protected override void OnOpenGlRender(GlInterface gl, int fb)
{
if (GL is not null)
{
GL.BindFramebuffer(GLEnum.Framebuffer, (uint)fb);
GL.Viewport(0, 0, (uint)Bounds.Width, (uint)Bounds.Height);
}
Dispatcher.UIThread.Post(RequestNextFrameRendering, DispatcherPriority.Render);
}
public bool HitTest(Point point)
{
return true;
}
}