i've built a program with piccolo2d/.net and all was going well until i added winform widgets to the form (and outside of the canvas); see pic below. thanks to
http://www.eqqon.com/index.php/Piccolo_Snippets, i had mousewheel zooming working well. but then i discovered that if i clicked on button1, and mouse back onto the canvas, i no longer get mousewheel events, although other mouse events (e.g. PNode entry/leave) still work. this tells me it's not that i needed to click on the canvas to move the focus. but even after clicking on the canvas, the mousewheel is still dead.
as a sanity check, i tested the canvas's mousedown event and found it works fine after clicking button1. so only the mousewheel breaks. what am i doing wrong? below is minimalist code to demonstrate what i'm seeing.
(as an aside, i see that the canvas does not raise "enter"/"leave" events consistently; i see one "enter" when the form loads and one "leave" if i click button1 but no more "enter"/"leave" if i go back and forth. further, when i click on button1, i raises its "enter" event but when i click back on the canvas, "button1" doesn't raise its "leave" event, which it does if i have other winform widgets on the form and i clicked on them.) thanks.
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;
PNode circle = PPath.CreateEllipse(20, 20, 30, 30);
circle.Brush = Brushes.Brown;
pCanvas1.Layer.AddChild(rect);
pCanvas1.Layer.AddChild(circle);
pCanvas1.Camera.MouseWheel += new PInputEventHandler(Camera_MouseWheel);
pCanvas1.Camera.MouseDown += new PInputEventHandler(Camera_MouseDown);
}
void Camera_MouseDown(object sender, PInputEventArgs e) {
Debug.WriteLine("got mouse down: " + (mdown_count++).ToString());
}
void Camera_MouseWheel(object sender, PInputEventArgs e) {
Debug.WriteLine("got mouse wheel: " + (mwheel_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");
}
}
}