Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!mintaka!bloom-beacon!eru!hagbard!sunic!news.funet.fi!ousrvr!news From: av@woo.oulu.fi.oulu.fi (Ari Vaulo, LuTK/TOL) Newsgroups: comp.sys.mac.hypercard Subject: Re: if there is ... at [xx,yy] Message-ID: <1991Mar30.180433.17363@ousrvr.oulu.fi> Date: 30 Mar 91 18:04:33 GMT References: <12497@pt.cs.cmu.edu> Sender: news@ousrvr.oulu.fi Organization: University of Oulu, Finland Lines: 84 From article <12497@pt.cs.cmu.edu>, by kem@h.gp.cs.cmu.edu (Kenneth Mohnkern): > I guess HC2.0's "there is" doesn't have the ability to check if > there's an object at a certain point. The manual doesn't cover > "there is" very well. I think it's only mentioned in a table of > functions (or commands? properties?) I tried "If there is a bg > btn at 442,42 then beep". I got an error message. > > Is there another way around this? I'd like to look at a specific > location and see if there's a button there without looking at > every button and comparing its loc with the desired loc. > > I know if there's a cool way to do this I'll find it here. > > Thanks, > ken > > -- > > ken mohnkern#the robotics institute#carnegie mellon univ#pittsburgh pa I solved that kind of problem by clicking at the point where I supposed that there could be a button or something else. But it requires special code on every possible target. First I tried (with HC 2.0) the following command: click at xloc,yloc It was easy to look using TARGET function which object was at location (xloc,yloc), but it was a bit harmful because it executes all the mouse* command handlers and I should modify the command with shift,command, and option keys: click at xloc,yloc with cmdkey and in possible targets on mouseUp if the cmdKey is "down" then exit mouseUp else {code what the button should normally do} end if end mouseUp And at last I found that the possible solution isn't elegant, but it works. You should put the following code in your script where you want to find other objects: ... global KLIKATTU,OSUMA put empty into OSUMA put "Joo" into KLIKATTU click at xloc,yloc put empty into KLIKATTU if OSUMA is not empty then {the name of the object located at xloc,yloc is in variable OSUMA} {and it could be anything card, button, field, and so on. ... And in every object where is either some mouse* handlers or are your possible targets you should put the following code: on mouseUp global KLIKATTU if KLIKATTU is empty then {code what the object should normally do} else global OSUMA put the name of me into OSUMA exit mouseUp end if end mouseUp I don't like global with object oriented like code, but sometimes it is MUST. I'm trying to do draughts (or checkers) game with HC (I'm not sure that it will be ever ready) and there I need this kind of scripts. Ari Ari Vaulo ---------------------------------------- eMail: av@tolsun.oulu.fi University of Oulu -------------------------------------------------------- Department of Information Processing Science ------------------------------ Finland --------------------------------------------- voice: +358-81-352647