Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!lll-tis!ames!ll-xn!husc6!endor!olson From: olson@endor.harvard.edu (Eric K. Olson) Newsgroups: comp.sys.mac.programmer Subject: Re: Blinking cursor in modeless dialog ... Message-ID: <4112@husc6.harvard.edu> Date: 24 Feb 88 20:39:47 GMT References: <11406@sgi.SGI.COM> Sender: news@husc6.harvard.edu Reply-To: olson@endor.UUCP (Eric K. Olson) Distribution: na Organization: Lexington Software Design, Lexington, MA Lines: 55 Keywords: DIALOG CURSOR BLINK In a recent article Michael Toy -- The S.G.I. XMAN writes: >I can't get the cursor to blink in a dialog box. All my previous dialog >boxes have been handled by "ModalDialog()" which does all the right things >for me. Inside Mac tells me that I need to call "IsDialogEvent" and then >"DialogSelect" after a "GetNextEvent" even if "GetNextEvent" returns false >in order for the TextEdit cursor in my modeless dialog box to blink. I >translated that statement to this code: > > if (GetNextEvent(everyEvent, &anEvent)) > /* > ** This is my event handler, it also calls IsDialogEvent and > ** DialogSelect > */ > handle_event(&anEvent); I use the following code: void dialTEidle(dialog) DialogPtr dialog; { TEIdle(((DialogRecord *) dialog)->textH); } void dialTEactive(dialog) DialogPtr dialog; { TEActivate(((DialogRecord *) dialog)->textH); } void dialTEdeactive(dialog) DialogPtr dialog; { TEDeactivate(((DialogRecord *) dialog)->textH); } with the following explanation: Keep in mind that you don't want the cursor to blink just in response to DialogSelect, since that is called in response to events. In your main loop, you should call dialTEIdle. If the Dialog allows itself to be deselected, you'll need dialTEActivate and dialTEDeactivate so that the caret knows when to go away and appear. Call them in response to Activate and Deactivate events in the Dialog's window. Note that this only works because the Dialog Manager shares a single TextEdit record among all the EditText items in the Dialog (otherwise, you'ld have to know which item is current, too). This is documented in Inside Mac (but seems like something subject to change). If it ever does change, this code will break. I know of no other way to do it; does anyone else? -Eric "We're writing tomorrow's software yesterday." Eric K. Olson olson@endor.harvard.edu harvard!endor!olson D0760 (Name) (ArpaNet) (UseNet) (AppleLink)