单击画布后未触发鼠标滚轮事件

时间:2016-05-23 12:19:08

标签: c# .net winforms mousewheel piccolo

感谢http://www.eqqon.com/index.php/Piccolo_Snippets,我的鼠标滚轮缩放工作正常,直到我将winform小部件添加到画布外的形式;见以下测试表的图片:

form with a piccolo canvas and winform button and trackbar

我发现如果我点击button1,然后再回到画布上,我就不再获得鼠标滚轮事件了。然而,其他鼠标事件(例如,PNode进入/离开)仍然有效。即使在点击画布后,鼠标轮仍然死了。帆布的mousedown活动也很好。所以只有鼠标轮坏了。下面是极简主义代码,用于展示我所看到的内容。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using UMD.HCIL.Piccolo;
using UMD.HCIL.Piccolo.Event;
using UMD.HCIL.Piccolo.Nodes;

namespace piccolo_wheel_test {
    public partial class Form1 : Form {

        int mdown_count = 0;
        int mwheel_count = 0;

        public Form1() {
            InitializeComponent();

            PNode rect = PPath.CreateRectangle(40, 40, 20, 50);
            rect.Brush = Brushes.Blue;
            pCanvas1.Layer.AddChild(rect);

            pCanvas1.Camera.MouseWheel += new PInputEventHandler(Camera_MouseWheel);
            pCanvas1.Camera.MouseDown += new PInputEventHandler(Camera_MouseDown);
        }

        void Camera_MouseWheel(object sender, PInputEventArgs e) {
            Debug.WriteLine("got mouse wheel: " + (mwheel_count++).ToString());
        }

        void Camera_MouseDown(object sender, PInputEventArgs e) {
            Debug.WriteLine("got mouse down: " + (mdown_count++).ToString());
        }

        private void pCanvas1_Enter(object sender, EventArgs e) {
            Debug.WriteLine("enter pcanvas");
        }

        private void pCanvas1_Leave(object sender, EventArgs e) {
            Debug.WriteLine("leave pcanvas");
        }

        private void button1_Enter(object sender, EventArgs e) {
            Debug.WriteLine("enter button");
        }

        private void button1_Leave(object sender, EventArgs e) {
            Debug.WriteLine("leave button");
        }

    }
}

作为旁白,我看到画布没有提升"输入" /"离开"事件一致;我看到一个"进入"当表单加载并且一个"离开"如果我点击button1但没有更多"输入" /"离开"如果我来回走动此外,当我点击button1时,我提出了"输入"事件,但当我回到画布上时," button1"没有提高其离开"离开"事件(如果我点击其他winform小部件,例如轨迹栏,它会这样做。)谢谢。

0 个答案:

没有答案
相关问题