On Feb 23, 2007, at 11:16 am, [EMAIL PROTECTED] wrote:

> On Feb 23, 2007, at 15:18 UTC, GregO wrote:
>
>> So I'm trying to implement a magnify cursor on a canvas that changes
>> to a MagnifySmaller cursor when the user is holding down the option/
>> alt key, but have not found an event that fires when that key is
>> pressed. How do I get it to change (short of expecting the user to
>> move the mouse to see the change). I realize that I could use a
>> timer, but I'm trying to bundle this all into one class if possible.
>
> You've considered all your options.  The user pressing or releasing a
> modifier key, by itself, is not an event.  So the only way to  
> detect it
> is to periodically check for it.
>
> But there is a way you can create a Timer in code, and bind it to
> yourself (er, your Canvas class) such that you get notification  
> when it
> fires.  It's not exactly ideal, but may be good enough for your
> purposes.  The trick is that Timer is a subclass of ActionBinder,  
> which
> defines an addActionNotificationReceiver method (as well as a
> corresponding "remove" method).  So, if you make your class implement
> the actionNotificationReceiver interface, then you can do something
> like this:
>
>   tim = New Timer   // where tim is a property of this class
>   tim.addActionNotificationReceiver self
>   tim.Mode = Timer.ModeMultiple
>   tim.Period = 500
>   tim.Enabled = true
>
> Now, whenever Tim the Timer fires, your PerformAction method (which is
> what the actionNotificationReceiver interface defines) is called.
>
> The reason I say this is not ideal is that if you have more than one
> timer (or other ActionBinder) to bind, you have no way of telling  
> which
> one is calling your PerformAction method.  It'd be better if
> PerformAction had a "source as ActionBinder" parameter, so if you have
> multiple sources of actions, you can take different action  
> depending on
> which one's invoking the method.  But, c'est la vie, no?  It's still a
> pretty neat trick, and often useful.
>
> Cheers,
> - Joe
>
> --
> Joe Strout -- [EMAIL PROTECTED]
> Verified Express, LLC     "Making the Internet a Better Place"
> http://www.verex.com/
>

Wow. That is just too cool! Thanks Joe!

GregO
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to