0

感谢http://www.eqqon.com/index.php/Piccolo_Snippets,在我将 winform 小部件添加到画布外部的表单之前,我的鼠标滚轮缩放效果很好;请参阅下面的测试表格图片:

带有 piccolo 画布和 winform 按钮和轨迹栏的表单

我发现如果我单击 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");
        }

    }
}

顺便说一句,我看到画布不会始终引发“进入”/“离开”事件;我在表单加载时看到一个“输入”,如果我单击按钮 1,我会看到一个“离开”,但如果我来回走动,则看不到更多“输入”/“离开”。此外,当我点击 button1 时,我会引发它的“enter”事件,但是当我在画布上点击返回时,“button1”不会引发它的“leave”事件(如果我点击其他 winform 小部件,例如轨迹栏。)谢谢。

4

0 回答 0