Hi I'm building an OpenGL component that's working rather nicely but the MouseWheel event is causing me grief. I'm wanting to capture the MouseWheel event call a user-defined event handler.
Assigning to OpenGL.OnMouseWheel didn't work (should have been OK) so I've overridden "Tcontrol.DoMouseWheel". DoMouseWheel is called whenever the mouse wheel is moved. It's happy for me to override "DoMouseWheel" (it complains if the parameter signatures aren't correct, so it does seem to be overriding the Tcontrol one). Everything seems works correctly but when I'm over the OpenGL component, my DoMouseWheel is ignored and Tcontrol.DoMouseWheel is still called, as though it hadn't been overriden. I'd already overridden "MouseDown" and it works as expected (as does MouseMove/MouseUp ...) but the Wheel Procedures seem to be different - I have no idea why ... In the code below, I've excerpted both "MouseDown" (which works) and "DoMouseWheel" which doesn't. Any idea what's wrong, is this a known problem, or is it just not my day? How does one go about tracing what's actually happening? Your thoughts would be appreciated ... Thanks Giovanni ======================================================================== Giovanni Moretti | Institute of Information Sciences and Technology Senior Lecturer | Massey University, Palmerston North, New Zealand Computer Science | Ph 64-6-3505799x2474 == Fax 64-6-3502259 == ZL2BOI ------------------------------------------------------------------------ http://www-ist.massey.ac.nz/moretti mailto:[EMAIL PROTECTED] (* relevant fragments of code ... *) TOpenGL=class(TGraphicControl) PRIVATE FonMouseDown : TMouseEvent; FonMouseWheel : TMouseWheelEvent; PUBLIC procedure MouseDown (Button : TMouseButton; Shift : TShiftState; X, Y : Integer); OVERRIDE; function DoMouseWheel(Shift: TShiftState; WheelDelta: integer; MousePos: TPoint) : Boolean; OVERRIDE; PUBLISHED property OnMouseDown : TMouseEvent read FOnMouseDown write FOnMouseDown; property OnMouseWheel : TMouseWheelEvent read FOnMouseWheel write FOnMouseWheel; end; {TOpenGL} //---------------------------------------------------------------------- // WORKS AS EXPECTED procedure TOpenGL.MouseDown(Button : TMouseButton; Shift : TShiftState; X, Y : Integer); var id : integer; begin if DetectHits(X,Y) then begin debugMessage('> Clicked on Object #' +intToStr(HitObject)); end; if assigned(FonMouseDown) then FonMouseDown(self, button, shift, X, Y); end; //---------------------------------------------------------------------- -- // This never gets called ... (even though is similar to MouseDown function TOpenGL.DoMouseWheel(Shift : TShiftState; WheelDelta : Integer; MousePos : TPoint) : Boolean; var beenHandled : boolean; begin beenHandled:= false; if assigned(FonMouseWheel) then // Let the user handle it FonMouseWheel(self, shift, WheelDelta, MousePos, beenHandled); // It they didn't handle it then pass it up to TControl if not beenHandled then beenHandled:= inherited DoMouseWheel(shift, WheelDelta, MousePos); result:= BeenHandled; end; ======================================================================== Giovanni Moretti | Institute of Information Sciences and Technology Senior Lecturer | Massey University, Palmerston North, New Zealand Computer Science | Ph 64-6-3505799x2474 == Fax 64-6-3502259 == ZL2BOI ------------------------------------------------------------------------ http://www-ist.massey.ac.nz/moretti mailto:[EMAIL PROTECTED] --------------------------------------------------------------------------- New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] Website: http://www.delphi.org.nz To UnSub, send email to: [EMAIL PROTECTED] with body of "unsubscribe delphi" Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/
