[comp.sys.amiga] ActivateGadget Use

Steve_A_Hales@cup.portal.com (12/08/87)

Auugghh!!

  As the deadline approaches, he hurries to remove all the *wierd* bugs.

I want to *activate* a string gadget upon entry to a dialog box.  I am using
Aztec 3.4b's ActivateGadget for Version 1.2 of Kickstart  But it don't seem
to work.

I actually got it to display the cursor very quickly in the STRGADGET box,
but then it disappears.

Does anyone know what's going on?  Does this work?  (It must because I see
it in other comercial products).

HELP HELP---

I would appreciate any clues to where to go next.

Thanks.

UUCP:   Steve_A_Hales@cup.portal.com

langz@athena.mit.edu (Lang Zerner) (12/08/87)

In article <1861@cup.portal.com> Steve_A_Hales@cup.portal.com writes:
>I want to *activate* a string gadget upon entry to a dialog box.  I am using
>Aztec 3.4b's ActivateGadget for Version 1.2 of Kickstart  But it don't seem
>to work.
>
>I actually got it to display the cursor very quickly in the STRGADGET box,
>but then it disappears.

You wouldn't happen to be using HeliosMouse, would you?  I witnessed the same
phenomenon as a user, and later realized that what was happening was that after
the string gadget activated itself, HeliosMouse was telling the system that I
had clicked at the point where the mouse was.  That point normally was not in
the string gadget, so the "click" deselected the string gadget almost instantly
after it came into existence.

As my great-uncle used to say, "Hope this helps."

--
Be seeing you...
--Lang Zerner      langz@athena.mit.edu   ...ihnp4!mit-eddie!mit-athena!langz
"No one is exempt from talking nonsense; the only misfortune is to do it
 solemnly"   --Michel de Montaigne

ewhac@well.UUCP (Leo 'Bols Ewhac' Schwab) (12/11/87)

In article <1861@cup.portal.com> Steve_A_Hales@cup.portal.com writes:
>I want to *activate* a string gadget upon entry to a dialog box.  I am using
>Aztec 3.4b's ActivateGadget for Version 1.2 of Kickstart  But it don't seem
>to work.
>
	Another poster mentioned that the cause may be HeliosMouse.
However, since the original poster (quoted above) didn't say if he was using
it, have a code fragment.  Note: This is an *extremely* cheesy file
requestor, and I don't recommend using it unless you're writing user-hostile
programs.

_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
Leo L. Schwab -- The Guy in The Cape	ihnp4!ptsfa -\
 \_ -_		Recumbent Bikes:	      dual ---> !{well,unicom}!ewhac
O----^o	      The Only Way To Fly.	      hplabs / (pronounced "AE-wack")
"Work FOR?  I don't work FOR anybody!  I'm just having fun."  -- The Doctor

_-_-_-_-_-_-_-_-_-_-_-_ Cut here!  Cut, I say!! _-_-_-_-_-_-_-_-_-_-_-_-_-_-_
/*  :ts=8 bk=0
 *
 * file.c:	Code and structures for super-cheesy file requestor.
 *		[USENET Note:  This was part of a larger program I wrote.
 *		You must #define BACKFILL, REQLEFT, and REQTOP to something,
 *		and there has to be a valid window somwehere.]
 *
 * Leo L. Schwab			8709.8
 */
#include <exec/types.h>
#include <intuition/intuition.h>

#define	REQWIDE		320
#define	REQHIGH		45

/*
 * Remeber to define these!
 */
/* #define	BACKFILL	something	*/
/* #define	REQLEFT		somethingelse	*/
/* #define	REQTOP		snark		*/

/*
 * Bounding box for filename gadget.
 */
static SHORT filebox[] = {
	-2, -2,
	-2, 9,
	289, 9,
	289, -2,
	-2, -2
};

static struct Border bord = {	/*  Border for gadget  */
 	0, 0,
	0, 0, JAM1,
	5,
	filebox,
	NULL
};


/*
 * Filename gadget special info.
 */
static UBYTE filename[256], ufilename[256];
static struct StringInfo filenamegad = {
	filename, ufilename,
	0, 256, 0,
	0, 0, 0, 0, 0, 0, 0, 0
};

/*
 * Gadget for filename requestor
 */
static struct Gadget file = {
	NULL,
	16, REQHIGH-20, 36*8, 10,
	GADGHCOMP,
	RELVERIFY | ENDGADGET,
	STRGADGET | REQGADGET,
	(APTR) &bord, NULL, NULL,
	0,
	(APTR) &filenamegad,
	0, 0
};

/*
 * IntuiText for requestor itself.
 */
static struct IntuiText reqtext = {
 	0, 0, JAM1,
	16, 10,
	NULL,
	(UBYTE *) "Please enter a filename.",
	NULL
};

/*
 * The requester
 */
static struct Requester filerequester;


/*
 * Code to initialize the file requester
 */
setupfilereq ()
{
	InitRequester (&filerequester);

	filerequester.LeftEdge	= REQLEFT;
	filerequester.TopEdge	= REQTOP;
	filerequester.Width	= REQWIDE;
	filerequester.Height	= REQHIGH;
	filerequester.ReqGadget	= &file;
	filerequester.ReqText	= &reqtext;
	filerequester.BackFill	= BACKFILL;
}

/*
 * Phew!  Now to write some real code.
 */
char *
getfile ()
{
	extern struct Window		*win;	/* Make sure this is real! */
	register struct IntuiMessage	*msg;
	register struct Gadget		*gad;
	long				class;

	/*
	 * In order to do ActivateGadget() properly, we have to officially
	 * wait for the requester to get posted.  Thus, the following
	 * mish-mash.  Note:  Your window must have the REQSET IDCMP flag
	 * set.  Otherwise, this will break.
	 */
	Request (&filerequester, win);
	while (1) {
		WaitPort (win -> UserPort);
		msg = GetMsg (win -> UserPort);
		class = msg -> Class;
		ReplyMsg (msg);
		if (class == REQSET)
			break;
	}
/*	ActivateGadget (GADGET_POINTER, WINDOW_POINTER, REQUESTOR_POINTER)  */
	ActivateGadget (&file, win, &filerequester);

	while (1) {
		WaitPort (win -> UserPort);
		msg = GetMsg (win -> UserPort);
		class = msg -> Class;
		gad = (struct Gadget *) msg -> IAddress;
		ReplyMsg (msg);
		if (class == GADGETUP && gad == &file)
			return ((char *) filename);
	}
}

peter@sugar.UUCP (Peter da Silva) (12/14/87)

From my Instant Application/Standard File program:

X	if(!(STD_Window = OpenWindow(&STD_NewWindow))) {
X		return 0;
X	}
X
X	/* This optional line will activate a string gadget	*/
X	if ( IntuitionBase->lib_Version > 32 )
X	{
X		ActivateGadget(gadget,STD_Window,0L);
X	}

This works fine. And will work under older versions of Intuition... just
won't have the gadget active. Shamelessly stolen from a sample program
on the Manx disk.
-- 
-- Peter da Silva  `-_-'  ...!hoptoad!academ!uhnix1!sugar!peter
-- Disclaimer: These U aren't mere opinions... these are *values*.