home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.next.programmer
- Path: 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
-
- 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
-
-