Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!apple!jdevoto From: jdevoto@Apple.COM (Jeanne A. E. DeVoto) Newsgroups: comp.sys.mac.hypercard Subject: Re: Q: replacing the selection on a button click ? Summary: use "the selectedChunk" Message-ID: <47794@apple.Apple.COM> Date: 6 Jan 91 15:44:56 GMT References: <1991Jan5.232644.29647@csn.org> Organization: Apple Computer Inc., Cupertino, CA Lines: 55 In article <1991Jan5.232644.29647@csn.org> wilde@boulder.Colorado.EDU (Nick Wilde) writes: >I have this field, ya see. The user clicks on said field, sets the >insertion point, maybe selects some text. Now, said user goes over >and clicks one of several buttons. Depending upon which button is >pushed, I want to replace whatever was selected in the field with >some text. The problem is as soon as the user clicks on the button, >"the selection" goes away, and I have no idea where to put the >text.... Let me guess: the button's autohilite property is turned on. When a button is hilited, the text selection is lost. You can get around the problem by turning off autohiliting, of course, but this solution is unappealing: for one thing, it removes an important element of user feedback. > Is there some way to get a >"description" of the selection, vs the selection itself ? Why is the >sky blue ? Do toilets really flush in the opposite direction due >to coriolis force in the southern hemisphere ? Does anybody care ? The function you're looking for is "the selectedChunk". This function returns a chunk expression such as "char 5 to 14 of card field ID 5". The basic strategy is to store the selectedChunk and then re-select it after your handler is finished. Add some code to fake auto-hiliting and you get something like: on mouseDown put the selectedChunk into mySelection repeat until the mouse is up -- autohilite if the mouseLoc is within the rect of the target then set the hilite of the target to true else set the hilite of the target to false end if end repeat if the mouseLoc is within the rect of the target then -- do button stuff end if set the hilite of the target to false select mySelection end mouseDown Because the atmosphere preferentially scatters red light. Depends on whether the inflow faucets are angled or not. I do! ;-) -- ========= jeanne a. e. devoto ======================================== jdevoto@apple.com | You may not distribute this article under a jdevoto@well.sf.ca.us | compilation copyright without my permission. ______________________________________________________________________ Apple Computer and I are not authorized | CI$: 72411,165 to speak for each other. |