2012-12-10 14 views
0

我想通過鼠標在DrawingArea中繪製圖像。我可以在DrawingArea中知道當前的鼠標座標,但我怎麼知道按下了什麼按鈕?我當前的代碼看起來像:DrawingArea的MouseButton的狀態

  protected void OnPaintedPicture1DrawingareaMotionNotifyEvent (object o, MotionNotifyEventArgs args) 
      { 
       EventMotion currentEventMotion = (args.Args[0] as EventMotion); 

       matchingPercentageForPicture1AndSample1_entry.Text+=String.Format("x='{0}'; y='{1}';\t", currentEventMotion.X, currentEventMotion.Y); 
      } 
+0

我認爲它的lParam變量,你可以正常使用鼠標狀態,但沒有得到任何證據支持這一點.. – Sayse

回答

0

你可以得到有關從currentEventMotion.State鼠標按鈕(和的功能鍵)的信息。它包含值爲Gdk.ModifierType

+0

謝謝,但用戶按鼠標按鈕時無法獲得MotionNotifyEvent。你可以告訴我如何按下按鈕時生成MotionNotifyEvent?現在我由下一個方式更改代碼:\t \t \t \t EventMotion currentEventMotion =(args.Args [0]作爲EventMotion); \t \t \t \t \t \t \t \t //第三比特 - 確實Ctrl鍵按壓 \t \t \t \t如果(!(Convert.ToInt32(currentEventMotion.State)Convert.ToInt32( 「000000100」,2))= 0) \t \t \t \t { \t \t \t \t \t matchingPercentageForPicture1AndSample1_entry.Text + =的String.Format( 「X = '{0}'; Y = '{1}'; \ t」 的,currentEventMotion.X,currentEventMotion.Y); \t \t \t \t} – Mixim

+0

你的問題似乎是有關從運動獲得按鈕狀態通知事件。如果您想在按下按鈕時獲取事件,請連接到「ButtonPressEvent」或「ButtonReleaseEvent」信號。 – ptomato