[英]Why the MouseLeave event is not triggered when folderbrowserdialog was open and selected a directory?
[英]When exactly is the MouseLeave event triggered?
根据此MSDN文章:“ MouseLeave事件是响应于对象边界区域之外发生的触摸事件而引发的。”。 但是在实现过程中,我发现它在释放对象边界区域的敲击时被触发(与OnMouseLeave一样)。
那么,如何在点击UI Object边界之外的同时触发它?
我是C#和StackOverflow的新手,但我想我可能会贡献我所发现的东西。 我在Google上对“”进行了快速搜索,找到了这篇有关检测GUI外部点击的文章 。
这是一个快速的方法/描述(位于链接中),它检测在GUI上方绘制的矩形之外的点击。 “当您使用GUI窗口或组/区域时,可以使用其Rect检查鼠标是否在其中。”
Rect windowPos = new Rect(10,10,200,150);
void OnGUI()
{
Event e = Event.current;
windowPos = GUI.Window(0, windowPos, drawWindow, "MyWindow");
if (e.type == EventType.MouseDown && !windowPos.Contains(e.mousePosition))
{
// Click was outside of the GUI window
}
}
void drawWindow(int aID)
{
// draw the window content
}
只需在该页面上阅读。 似乎以前已经回答了他们的问题。
祝好运!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.