Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!hoptoad!tim From: tim@hoptoad.uucp (Tim Maroney) Newsgroups: comp.sys.mac.programmer Subject: Re: A couple of problems a beginner is having. . . Message-ID: <7819@hoptoad.uucp> Date: 30 Jun 89 19:43:41 GMT References: <42687@tiger.oxy.edu> Reply-To: tim@hoptoad.UUCP (Tim Maroney) Organization: Eclectic Software, San Francisco Lines: 121 In article <42687@tiger.oxy.edu> adams.e@oxy.edu (Erik Adams) writes: > 1.) If I move an application window on top of a system >window (the control panel, for example), and then move it away, >the system window is _not_ updated. Where the application window >was is now a white outline in the system window. The only thing I can think of is that you're calling GetOSEvent rather than GetNextEvent or WaitNextEvent. If you call GetNextEvent or WaitNextEvent, SystemEvent is called by the OS to handle (among other things) update events for desk accessory windows. Don't use GetOSEvent, as it is incompatible with MultiFinder. If you *are* using GetNextEvent, I admit bafflement. > 2.) I can not get a scroll bar in a modal dialog to work. >Here is what I am currently doing: I pass to ModalDialog a >pointer to a FilterProcedure. The Filterprocedure checks to see >where theEvent is. If theEvent is in the scroll bar, I call >TrackControl, passing it an ActionProcedure. I get, at various >times with various combinations: nothing at all; a scroll bar >that highlights correctly but does not change its value; a scroll >bar that both hightlights and moves, but only when you mouseDown >about 16 pixels to the left; and more system crashes of varying >sorts than I care to enumerate. The problem seem to be with >my figuring out whether or not theEvent is in the scroll bar, >but there appears to be more than just that. This is a pretty advanced task for a beginning Mac programmer. I think there are probably a few problems. First, the scroll bar should be completely enclosed by a userItem, or declared as a CNTL item. If you don't do this, then you will have updating problems. Second, make sure you understand the difference between local and global coordinates. When you get an event, the where field will be in global coordinates. You need to convert to local coordinates before determining where it falls in your dialog. To do this, you need to be sure the current port is the dialog window, then call GlobalToLocal. Third, it is generally better *not* to do this directly; instead, pass the point to FindWindow and then to FindControl. This should take care of determining whether the mouse click is in the control or not, and if so, in which part. Fourth, you may be having clipping problems; it shouldn't hurt to do a "ClipRect(&dialog->portRect);" before doing anything with the scroll bars. Fifth, it is generally better to have a bunch of different action procedures, one for each part. Here's a tracking routine I use a lot. Obviously, you don't have all the context for this, and this controls both vertical and horizontal scroll bars, but it ought to give you the idea. Note that FindWindow and FindControl have already been called, and the "where" parameter is in local coordinates. void ScrollClick(window, extra, ch, where, part) WindowPtr window; WindowExtra **extra; ControlHandle ch; Point where; short part; { ControlHandle new; ClipRect(&window->portRect); switch (part) { case inUpButton: if (ch == (*extra)->vScroll) TrackControl(ch, where, ScrollVUp); else TrackControl(ch, where, ScrollHUp); break; case inDownButton: if (ch == (*extra)->vScroll) TrackControl(ch, where, ScrollVDown); else TrackControl(ch, where, ScrollHDown); break; case inPageUp: do { if (ch == (*extra)->vScroll) ScrollVPgUp(ch, part); else ScrollHPgUp(ch, part); GetMouse(&where); } while (StillDown() && FindControl(where, window, &new) == part && ch == new); break; case inPageDown: do { if (ch == (*extra)->vScroll) ScrollVPgDn(ch, part); else ScrollHPgDn(ch, part); GetMouse(&where); } while (StillDown() && FindControl(where, window, &new) == part && ch == new); break; case inThumb: if (TrackControl(ch, where, 0)) ScrollThumb(window, ch); break; } } > I am using LSC 2.01 on a Mac 512ke, using older (pre-6.0) >versions of the Finder and System. Get more memory. The Dove upgrades are excellent -- reliable, easy to install, and cheap. A develoment system needs at least one megabyte and preferably at least 2.5 Megs. You also need to use the latest System and Finder and the latest development system. You're dancing with the devil in the pale moonlight if you don't. Hoep this helps! -- Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com Postal: 424 Tehama, SF CA 94103; Phone: (415) 495-2934 "The Diabolonian position is new to the London playgoer of today, but not to lovers of serious literature. From Prometheus to the Wagnerian Siegfried, some enemy of the gods, unterrified champion of those oppressed by them, has always towered among the heroes of the loftiest poetry." - Shaw, "On Diabolonian Ethics"