Home » Community » Newbie corner » How to compare child in function virtual void ChildMouseEvent with ctrl’s value.
Re: How to compare child in function virtual void ChildMouseEvent with ctrl’s value. [message #27617 is a reply to message #27586] |
Mon, 26 July 2010 11:05   |
mrjt
Messages: 705 Registered: March 2007 Location: London
|
Contributor |
|
|
I haven't run your test case (you really should post test-cases that don't require any external headers/libs if you want people to try them) but I think I can see the problem.
The GLCtrl contains a child Ctrl (GLPane) that is the actual native window that the OpenGL context is attached to. It is this Ctrl that recieves the MouseEvents. It then passes them up to the GLCtrl to seem as if the GLCtrl recieved them but this results in ChildMouseEvent not being called for the GLCtrl's parent.
Some solutions:
- Don't use ChildMouseEvent. I tend to do my rendering in a GLCtrl derived class that can handle mouse events and camera stuff internally.
- This is a bit of a hack, and the least preferrale option, but changing the test to ctrl->GetParent() == &gl_control would work.
- Fix the bug in GLCtrl:
Image GLCtrl::GLPane::MouseEvent(int event, Point p, int zdelta, dword keyflags)
{
p = p - GetScreenView().TopLeft() + ctrl->GetScreenView().TopLeft();
// Make sure we send ChildMouseEvent
if (ctrl->GetParent())
ctrl->GetParent()->ChildMouseEvent(ctrl, event, p, zdelta, keyflags);
return ctrl->MouseEvent(event, p, zdelta, keyflags);
} (GLCtrl.cpp)
- Remove the need for the hacked mouse handling completely - this is the way it should be done IMO. Remove the MouseEvent function from GLCtrl::GLPane and add an IngoreMouse call in it's constructor:
GLPane() : WindowContext(NULL) { NoWantFocus(); IgnoreMouse(); } (Note that the changes need to be made to both the X11 and Win32 versions of GLPane)
[Updated on: Mon, 26 July 2010 11:11] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Sun Jun 22 11:59:05 CEST 2025
Total time taken to generate the page: 0.04061 seconds
|