🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.next.programmer
Article #1786

Can a View delegate its event handling capability?

#1786
From: Rick Mohr
Date: Mon, 16 Nov 1992 13:13
28 lines
1876 bytes
Can a View delegate its event handling capability?

Think of a standard document-based app with a document window and a tool bar.
Each tool establishes its own set of event meanings; for example, "mouseDown
and drag" might mean "select an object and move it" to a pointer tool and
might mean "create a rectangle and size it" to a box-creation tool.

In the obvious implementation, a View object receives an event, checks a
"selectedTool" variable and interprets the event accordingly.

But it would be nice if the tools could be written in an object-oriented
fashion, each providing its own method for mouseDown and any other events it
wanted to handle.  I can't think of any way of doing this that doesn't require
the View to declare its own mouseDown method, check what tool is selected, and
call that tool's mouseDown method.  Not much code, to be sure, but the View
must provide such a method for ALL events that some tool might want to catch.
Making the tool the first responder would work for some events but not others.

When a window object receives a "mouseDown" event message from the window
manager it determines what View gets first crack at the event and sends it a
mouseDown: message.  What I want is some way for the view to say "instead of
sending ME event messages, send them instead to HIM (the selected tool
object)."  Do I have to subclass window and duplicate the event distribution
capability??

Email responses appreciated.

-Rick
Technical Details
Message-ID: <199211162313.AA25672@NEBULA.SYSTEMSZ.CS.YALE.EDU>
Path: arc1-ca.pugleaf.net!sparky!uunet!gumby!yale!cs.yale.edu!news-mail-gateway!daemon

Show Full Headers
Complete Article Headers
Newsgroups: comp.sys.next.programmer
Path: arc1-ca.pugleaf.net!sparky!uunet!gumby!yale!cs.yale.edu!news-mail-gateway!daemon
From: mohr-eric@CS.YALE.EDU (Rick Mohr)
Subject: Can a View delegate its event handling capability?
Message-ID: <199211162313.AA25672@NEBULA.SYSTEMSZ.CS.YALE.EDU>
Sender: mohr-eric@CS.YALE.EDU
Organization: Yale CS Mail/News Gateway
Date: Mon, 16 Nov 1992 13:13:00 GMT
Lines: 29