[英]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.