Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Drawing feedback for mouse operations



On Thu, 8 Jun 2006 17:40:21, Rick Mann <email@hidden> wrote:

> I've brought this subject up before, and I usually get convinced of
> the right way to do it. Then I get distracted from this project for
> months, and forget it all. So, here it is again:
> 
> I am developing a non-trivial CAD application. It supports many
> different tools, so I have a "mouse handler" architecture: an
> instance of the current tool is set to be current, and mouse events
> are sent to it for handling.
> 
> In some tools, keys can be pressed during button-down periods. For
> this reason, I don't want to use TrackMouseLocation(); I'd rather
> maintain state, and let key events be handled appropriately.
> 
> A great deal of drawing takes place in response to mouse events. Just
> pointing at an object on the canvas can result in drawing as it's
> highlighted, for example.
> 
> To complicate matters, there is an almost-always non-identity
> transform applied; the user can zoom in and pan all over the canvas,
> and clicking needs to be translated into canvas coordinates (inverse
> of the CG context's transform).
> 
> My understanding from past experience is that I really can't get the
> view's CGContext from within a mouse event (for the purposes of doing
> an inverse transformation),

Conceptually, mousing involves proper coordinates calculations,
so I'd expect CGContext to be used internally within mouse events,
maybe just not exposed... See below.

> and that I shouldn't do drawing, either.

That's true. Though if absolutely necessary, there is HIViewRender.

> I can probably live with the latter, but I really want to build my
> model during the event.
> 
> The alternative is to store the last mouse position, set some state,
> ask for the view to be redrawn, and do everything in the redraw. I
> don't like this for any number of reasons.

What reasons?
Looks like a good approach.

> My biggest concern is that
> I've been told the context is unreliable during a mouse event.

That's something I don't understand: how mousing could work
properly if there is no proper CGContext (that establishes
coordinate transformations)?

Mike

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden

References: 
 >Drawing feedback for mouse operations (From: Rick Mann <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.