[lazarus] Progress

Michael A. Hess mhess at miraclec.com
Wed Sep 1 15:57:38 EDT 1999


Shane Miller wrote:
> 
> Actually, you can create new "events" for the components simply by
> using the DISPATCH method.  For example, in my code I may need to
> detect a "move mouse right" event and a "move mouse left" event.  So
> in my code I create a const
> 
> LM_MOVEMOUSERIGHT = NUMBER;
> LM_MOVEMOUSELEFT = NUMBER +1;
> 
> then in the mouse move event (that gtk sends) I track and detect if it
> is moving right or left.
> If moving_right then
>     Dispatch(LM_MOVEMOUSERIGHT)
> else
>    Dispatch(LM_MOVEMOUSELEFT);
> 
> in the component, obvoiusly I will have a
> Procedure MoveRight(var msg); message LM_MOVEMOUSELEFT;
> etc.
> In that procedure I do a
> If Assigned(SomeProcedure) then
>   Someprocedure(sender);
> 
> So, to the user of that component it appears to have a movemouseleft
> and movemouseright event.
> This will not be easy for very complicated events, but that's how it's
> done.

But this works if and only if the current component fires a callback for
a mousemove event. If the component doesn't support that then there is
no way to add the mousemove event to the GTK component. That is the
point I am trying to make everyone understand. If the event isn't
already supported by the component (and I am not talking about the user
designed event like above) which will deliver a callback then you can't
add the event. The only way to add it would be to modify the "C" code in
the GTK library.


> Think about it, if you create a component that extends itself off of
> TBUTTON and want to add events that aren't handled by default, you
> have to do a dispatch or call a procedure manually.

Exactly what do you think you could call to get the GTKMain event loop
to recognize and send a callback for an event it wasn't designed to
handle?

-- 
==== Programming my first best destiny! ====

Michael A. Hess      Miracle Concepts, Inc.
mhess at miraclec.com   http://www.miraclec.com






More information about the Lazarus mailing list