2013-10-21 164 views
0

我遇到鼠標事件問題!ILNumerics鼠標事件

我訂閱了事件MouseEnter和MouseLeave。 如果我的鼠標光標示例位於面板的中心,MouseEnter和MouseLeave事件觸發,爲什麼?

我的目標是感知,從鼠標光標位於3D PlotCube上的時候開始,當不在時。

代碼:

scene.MouseEnter += ILSurface_MouseEnter; 
scene.MouseLeave += ILSurface_MouseLeave; 
+0

你在說什麼語言?我無法從您的問題中猜出 –

+0

您是否閱讀過文檔? http://ilnumerics.net/mouse-events.html - 請發佈最小(!但完整)的代碼示例,並準確描述您期望的內容以及您的觀點。謝謝! –

回答

0

的曲線立方體捕捉事件的ScreenRect矩形的整個區域。在標準設置中,這個矩形被設置爲(0,0,1,1),其填充整個面板。所以,除非在面板上有多個繪圖立方體/相機,否則鼠標基本上總是在繪圖立方體上。

爲了顯示MouseEnter和MouseLeave事件的功能,我會發佈一個例子,它將在劇情立方體內作用於劇情。當鼠標輸入圖表時,它在窗體的標題欄中寫入「On Plot」。只要鼠標離開繪圖,就會寫入「關閉繪圖」。

開始與這裏示出的新鮮面板和設置ILNumerics如:爲了http://ilnumerics.net/visualization-api-quick-start-guide.html

將一個ILPanel到1並雙擊它切換到自動的代碼生成ilPanel1_Load事件處理程序。用下面的代碼替換處理:

private void ilPanel1_Load(object sender, EventArgs e) { 

    var surfPlot = new ILSurface(ILMath.tosingle(ILSpecialData.sincf(50, 40))) { 
     Colormap = Colormaps.Prism 
    }; 

    var pc = ilPanel1.Scene.Add(new ILPlotCube(twoDMode: false) { 
     surfPlot 
    }); 

    surfPlot.MouseEnter += (_s, _a) => { 
     if (!_a.DirectionUp) 
      Text = "On Plot - Target: " + _a.Target.ToString(); 
    }; 
    surfPlot.MouseLeave += (_s, _a) => { 
     if (!_a.DirectionUp) 
      Text = "Off Plot - Target: " + _a.Target.ToString(); 
    }; 
} 

這將產生類似於下面的圖像的結果: Hadling Mouse Enter and Mouse Leave in ILNumerics

形式的標題現在反映,如果鼠標在情節或者不是。請注意,無論圖形的旋轉/形狀如何,這都可以工作。 ILNumerics中有關鼠標事件處理的完整文檔可以在這裏找到:http://ilnumerics.net/mouse-events.html