[comp.sys.apple] CDEV problem..

dougm@pnet51.orb.mn.org (Doug Mcintyre) (10/03/89)

        I'm having a problem with my little CDEV that I've written.. The
particular problem I'm having is with Hilit ing an Icon button.. Here is my
Orca/C code.. (Note, since I am doing a CDEV from C, the only thing that
doesn't get set right is the databank register, so I can't use globals..)


voiddo_hit(ctlHndl,ctrlID)
CtlRecHndl ctlHndl;
long ctrlID;
{
        static int temp=0;
        temp = 1-temp;
        if (ctrlID == 2)
                HiliteControl(temp,ctlHndl);
}
ctrlID is an Icon button, and it is a resource drawn with NewControl2(), The
problem I'm having is that once I hit the button, it stays on for good... 
Should I assume this is yet another bug of Orca/C producing bad code, or is
there something weird with the toolbox, that it can't flash a hilited button?

I've tested the static binary switch, out of this context and it seems to be
working ok there.. but not in this particular code..


UUCP: {rosevax, crash}!orbit!pnet51!dougm                Compuserve: 70611,2215
ARPA: crash!orbit!pnet51!dougm@nosc.mil                        ALPE: DougMac
INET: dougm@pnet51.cts.com                                    GENIE: D.MCINTYRE1

dlyons@Apple.COM (David Lyons) (10/05/89)

In article <1207@orbit.UUCP> dougm@pnet51.orb.mn.org (Doug Mcintyre) writes:
>[...]
>void do_hit(ctlHndl,ctrlID)
>CtlRecHndl ctlHndl;
>long ctrlID;
>{
>    static int temp=0;
>    temp = 1-temp;
>    if (ctrlID == 2)
>      HiliteControl(temp,ctlHndl);
>}
[...]
>problem I'm having is that once I hit the button, it stays on for good... 
>Should I assume this is yet another bug of Orca/C producing bad code, or is
>there something weird with the toolbox, that it can't flash a hilited button?

Technically, you should be using 14 ($E) as the part code for hiliting an Icon
button (since that's what FindControl returns), but that's not your immediate
problem (any nonzero value seems to hilite it for me).

You might check whether ORCA/C is accidentally initializing temp to 0 every
time your procedure gets called...it's a tempting explanation.
-- 

 --Dave Lyons, Apple Computer, Inc.          |   DAL Systems
   AppleLink--Apple Edition: DAVE.LYONS      |   P.O. Box 875
   America Online: Dave Lyons                |   Cupertino, CA 95015-0875
   GEnie: D.LYONS2 or DAVE.LYONS         CompuServe: 72177,3233
   Internet/BITNET:  dlyons@apple.com    UUCP:  ...!ames!apple!dlyons

   My opinions are my own, not Apple's.

dlyons@Apple.COM (David Lyons) (10/05/89)

In article <35267@apple.Apple.COM> dlyons@Apple.COM (David Lyons (me)) writes:
>[...]
>You might check whether ORCA/C is accidentally initializing temp to 0 every
>time your procedure gets called...it's a tempting explanation.

Whoops--I see Doug found the real problem, so I take that back.
-- 

 --Dave Lyons, Apple Computer, Inc.          |   DAL Systems
   AppleLink--Apple Edition: DAVE.LYONS      |   P.O. Box 875
   America Online: Dave Lyons                |   Cupertino, CA 95015-0875
   GEnie: D.LYONS2 or DAVE.LYONS         CompuServe: 72177,3233
   Internet/BITNET:  dlyons@apple.com    UUCP:  ...!ames!apple!dlyons

   My opinions are my own, not Apple's.