Drawing while handling events (was Re: scribbling)
Drawing while handling events (was Re: scribbling)
- Subject: Drawing while handling events (was Re: scribbling)
- From: Fritz Anderson <email@hidden>
- Date: Wed, 13 Aug 2003 14:32:08 -0500
On Wednesday, 13 August 2003, at 1:56 PM, John Randolph wrote:
First suggestion: don't do any drawing in an event-handling method,
and don't call -lockFocus yourself. Just update the info you need to
do the drawing, and call -setNeedsDisplayInRect:.
May I ask you to explore this more closely? This seems to contradict
the example in the tasks-and-concepts documentation for mouse-event
handling in NSViews, "Handling Mouse Events in Views,"
<file:///Developer/Documentation/Cocoa/TasksAndConcepts/
ProgrammingTopics/BasicEventHandling/Tasks/HandlingMouseEvents.html>
The document says, "NSViews that handle mouse clicks as a single event,
from mouse down, through dragging, to mouse up, must usually
short-circuit the applications normal event loop, entering a modal
event loop to catch and process only events of interest." It then
provides an example of a mouseDown: handler implementing a loop on
-[NSWindow nextEventMatchingMask:], which calls drawing methods. I
could see how the equivalent program mode could be handled by
state-sensitive mouseUp: and mouseDragged: methods, but it would be a
lot uglier.
Are you disagreeing, or are you saying it's OK to draw in that case
where the state from mouse-down to mouse-up amounts to a unique, modal
event? But if the latter is the case, why isn't "scribbling" with the
mouse the same sort of state?
I'm not arguing; I want to learn.
-- F
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.