Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!rosie!sstreep From: sstreep@next.com (Sam Streeper) Newsgroups: comp.sys.next Subject: Re: Capturing mouse actions Message-ID: <441@rosie.NeXT.COM> Date: 2 Apr 91 21:42:39 GMT References: <0094684B.EDD0D820@uno.edu> Sender: news@NeXT.COM Organization: Next Computer, Inc. Lines: 41 Nntp-Posting-Host: elvis.next.com In article <0094684B.EDD0D820@uno.edu> jrscs@uno.edu writes: > > Does anyone know how I can capture the mouse's selecting a text area >by highlighting? When the user selects some text, I would like to make >available an option to call up Webster to define the word. Calling up >Webster is no problem; it's knowing when the Webster option should be >enabled by checking if the user has highlighted a word with the mouse >that I'm not sure about. What you want to do requires virtually no work. If you are using NeXTstep 2.0 and you use interface Builder, all you need to do is drag a "Services" menu from interface Builder into your application. Then, run the app. You can either select "define in webster" from the services menu or type 'command =' to define the current selection. --------------------------------------- Here's how it works (in short) The application object periodically asks the first responder (in your case, the text object) what data types it is willing to place on the pasteboard. When you have made a selection, the text object says that it is willing to place an ascii version of the selection on the pasteboard. The Application object then enables all services that are willing to act upon ascii data on the pasteboard. Since Webster can do that, the "Define in Webster" service is enabled. When you select this menu, Webster is invoked to act upon the pasteboard data, thus defining your word. (This is really a cursory examination of what happens, the 2.0 release notes provide a somewhat more complete and coherent description of the process. (maybe not?) 8^) -sam -- Opinions are not those of my employer. They're not even mine. They're probably wrong besides. How did they get in here, anyway?