Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!rutgers!njin!princeton!phoenix!bskendig From: bskendig@phoenix.Princeton.EDU (Brian Kendig) Newsgroups: comp.sys.mac.hypercard Subject: Re: Making areas of field text clickable? Message-ID: <13831@phoenix.Princeton.EDU> Date: 14 Feb 90 02:05:10 GMT References: <3811@accuvax.nwu.edu> Reply-To: bskendig@phoenix.Princeton.EDU (Brian Kendig) Organization: Systems Engineering, NASA Space Station Freedom Project Lines: 59 In article <3811@accuvax.nwu.edu> neves@aristotle.ils.nwu.edu (David Neves) writes: >I have many field texts. I want to make most of the text in these >fields sensitive to clicks. The 2 ways of doing this are: >1. Have the field (on mousedown or mouseup) figure out what text the user has >clicked on. This gets messy because the only RETURNs in the fields >are between paragraphs and the font is variable width. To do this one >would have to write an XCMD that used the character width information >and a good guess as to the word wrap routine that Hypercard (in my >case, Supercard) was using. That's the way, and although it's complicated, you don't need to resort to an XCMD to deal with it. Put a mouseUp handler into the field script. When activated, it should unlock the field, click twice at the clickLoc, read the selectedText and/or the selectedChunk, lock the field again, then process the read information. You needn't worry at all about the position of carriage returns in the field's text, nor of the text's size and attributes. The hard part is figuring out what to do with the stuff you read by automatically double-clicking. I decided to process the selectedChunk. I would use the text from the beginning of the word double-clicked on to the next space after it. (Remember that the selectedChunk returns phrases like `char 123 to 127 of card field "Text"', so it's not terribly bad to take care of. I would use the text from `char 128 of cd fld "Text"' to the next space, determined seperately, to avoid having hyphens and slashes break my words.) >2. Put buttons over all the text. I don't want to do this by hand >because I might change the field width or the text font. Both of >these would affect the positioning of words and so the buttons would >not longer be under the correct words. No! No! Aack! Don't *do* that! >It is not trival to get a program to do this automatically. The only >way that I could think of doing this is to start at the left part of >the field and gradually (pixel by pixel) select larger chunks of text >by using DRAG or CLICK. Because the program is doing the dragging you >know the left and right pixel positions of the selected text >underneath. As always with HyperCard and the Macintosh, the best solution is the most intuitive one. The one you suggest ain't intuitive. >Before we write this sad kludge I wonder if anyone else has run into >problem or see an obviously easier way of doing it. I have, actually, and if sufficiently persuaded and/or kicked hard enough, I might decide to put it into a sample stack for Public Consumption. Or I might decide to rewrite it. Ya nevah know. << Brian >> -- | Brian S. Kendig \ Macintosh | Engineering, | bskendig | | Computer Engineering |\ Thought | USS Enterprise | @phoenix.Princeton.EDU | Princeton University |_\ Police | -= NCC-1701-D =- | @PUCC.BITNET | | Systems Engineering, NASA Space Station Freedom / General Electric WP3 |