[comp.sys.amiga] Question on requestors

wecker@cookie.dec.com.UUCP (02/18/87)

Ok, my turn for a simple one:

	I have a requestor that contains a string gadget. All I want to do
	is have the requestor come up and PRESELECT the string gadget so
	if the user types, inputs will go directly to the gadget.

	Default is that the user must first select the gadget before input
	can occur. If I turn on the SELECTED bit in the gadget, a cursor
	comes up at the BEGINNING of the gadget and input is NOT directed
	toward the gadget.

	If I then click on the gadget, the cursor moves from the beginning
	of the gadget to the end, and input can occur.

	What am I doing wrong? All I want to do is prompt for input.

	BTW:	I'm running under 1.2

thanks!
dave	USENET:	{decwrl|decvax|decuac}!cookie.dec.com!wecker
	ARPA:	wecker%cookie.dec.com@decwrl.dec.com

cmcmanis@sun.UUCP (02/19/87)

In article <8136@decwrl>, wecker@cookie.dec.com (DAVE WECKER) writes:
} Ok, my turn for a simple one:
} 
} 	I have a requestor that contains a string gadget. All I want to do
} 	is have the requestor come up and PRESELECT the string gadget so
} 	if the user types, inputs will go directly to the gadget.

Dave, and others look in the 1.2 AutoDocs for the function ActivateGadget().
That will do what you want.

} thanks!
} dave	USENET:	{decwrl|decvax|decuac}!cookie.dec.com!wecker

No, thank you for a wonderful terminal emulator!

-- 
--Chuck McManis
uucp: {anywhere}!sun!cmcmanis   BIX: cmcmanis  ARPAnet: cmcmanis@sun.com
These opinions are my own and no one elses, but you knew that didn't you.

papa@bacall.UUCP (02/20/87)

> Ok, my turn for a simple one:
> 
> 	I have a requestor that contains a string gadget. All I want to do
> 	is have the requestor come up and PRESELECT the string gadget so
> 	if the user types, inputs will go directly to the gadget.
>

This is the way I do it in A-Talk (and A-Talk Plus) and it works ONLY under
1.2 since I use ActivateGadget().

1. Set the window to use the REQSET IDCMP message.
2. Display the requester as usual.
3. When you get REQSET message, do the following:
   - check if version id >=33
   - if it is, call ActivateGadget(gadget, window, requester)
(Note that when the requester appears you WILL get a REQSET message.)

That's it.

I think also EGAD! uses ActivateGadget, so you might want to look in there
to see if they do it differently.

-- Marco Papa
   Felsina Software

 

ali@navajo.UUCP (02/25/87)

In article <8136@decwrl>, wecker@cookie.dec.com (DAVE WECKER) writes:
> I have a requestor that contains a string gadget. All I want to do
> is have the requestor come up and PRESELECT the string gadget so
> if the user types, inputs will go directly to the gadget.

Well, as has been answered, you use ActivateGadget() under 1.2... A friend
of mine was pretty disappointed when she discovered this halfway through
her program, which was due for a class the next day. Anyway, quick hack 
she came up with was to actually simulate the I/O event and make intuition
think the mouse actually moved on top of the gadget and clicked it...

Anyway, here's the section of code that did this... Note that 
ActivateGadget() makes this sort of thing unnecessary, although you
might find the following code, written by Lee Taran, to be useful
if you actually want to move the mouse around (for demos, etc...).

------

/* Piece of code showing how to select a gadget by actually moving the mouse
   and selecting the gadget under program control... This code is not
   complete (the code to open libraries etc was removed as it is all
   pretty straightforward). 

   Written by Lee Taran (taran@Sushi.stanford.edu), July 1987
*/

#include <exec/types.h>
#include <exec/io.h>
#include <exec/memory.h>
#include <exec/devices.h>
#include <devices/inputevent.h>
#include <devices/input.h>
#include <intuition/intuition.h>

struct IntuitionBase *IntuitionBase; 
struct GfxBase *GfxBase;

struct Window *Window;
struct Screen *Screen;

/* used to generate my own i/o request  see Select_CmdG */
struct IOStdReq *ioreq;    

/* SetupEnvironment : Opens the libraries, initializes the screen and window
 * that will be used and then activates the command gadget. 
 */ 
SetupEnvironment()
{
  /* Code taken out to open the standard libraries (intuition,
     graphics), then open custom screen (pointed to by
     Screen) and a window within the screen (pointed to be Window) */
  
  /* Initialize the IO device stuff necessary to fake mouse events... */

  if (!(ioreq = CreateStdIO(Window->UserPort))) panic("No IO Req");
  if (OpenDevice("input.device",0,ioreq,0)) panic ("No IO Device");

  Select_CmdG();    /* The command gadget is selected at startup */
}

/* close_things : closes the Libraries that have been opened and
 * frees up whatever memory has been used.
 */
close_things()
{ 
  if (ioreq) { CloseDevice(ioreq); DeleteStdIO(ioreq); }
  /* Close window, screen, libraries, etc.. */
}


/* This is a real kludge. Select_CmdG() generates a phoney gadget
 * selection event so that Intuition will think that the user
 * has selected the cmd_gadget.  This saves the user the
 * trouble of having to select and reselect the command window
 * over and over. Set MOUSEBUTTONS IDCMP flag for window when opening it!
 * Obviously this function could be mad more general by passing the
 * gadget in as an argument, but you get the general idea.
 */
Select_CmdG()
{ struct InputEvent phoney;

  /* create a phoney i/o event */
  ioreq->io_Command = IND_WRITEEVENT;
  ioreq->io_Flags = 0;
  ioreq->io_Length = sizeof(struct InputEvent);
  ioreq->io_Data = &phoney;

  /* initialize the phoney event */
  phoney.ie_NextEvent = NULL;
  phoney.ie_Class = IECLASS_RAWMOUSE;
  phoney.ie_TimeStamp.tv_secs = 0;
  phoney.ie_TimeStamp.tv_micro = 0;
  phoney.ie_Code = IECODE_LBUTTON;
  phoney.ie_Qualifier = IEQUALIFIER_RELATIVEMOUSE;

  /* re-position mouse cursor over the command window -- somewhere
   * in the window but out of the way (so as not to distract the
   * user. The following code works for lo res non interlaced screen,
   * with the preferences mouse speed set to 1 (fastest). The factor of "2" 
   * might need to be changed for other type of screens... CMD_LEFT,
   * CMD_WIDTH, etc, define the border around the command gadget to be 
   * selected. 
   */
  phoney.ie_X = (WORD)2*(CMD_LEFT + CMD_WIDTH - 2 - Window->MouseX);
  phoney.ie_Y = (WORD)2*(CMD_TOP + 2 - Window->MouseY);
  
   /* queue up the i/o event so that Intuition will grab it */
  DoIO(ioreq);
}

wagner@gpu.utcs.toronto.edu (03/10/87)

In article <1410@navajo.STANFORD.EDU> ali@navajo.UUCP (Ali Ozer) demonstrates 
some code:
>
>   Written by Lee Taran (taran@Sushi.stanford.edu), July 1987
                                                     ^^^^^^^^^
Really? I feel like Rip Van Winkle! 
And I thought I was only off in California for two weeks! :-)

Michael

ali@rocky.UUCP (03/11/87)

In article <1987Mar10.012028.19770@gpu.utcs.toronto.edu> 
Michael Wagner writes:
>In article <1410@navajo.STANFORD.EDU> ali@navajo.UUCP (Ali Ozer)
>demonstrates some code:
>>   Written by Lee Taran (taran@Sushi.stanford.edu), July 1987
>                                                     ^^^^^^^^^
>Really? I feel like Rip Van Winkle! 
>And I thought I was only off in California for two weeks! :-)

Ok, ok, I screwed up.

No, no, actually, I used the public domain "TimeTravel" program. It
is written in C, and runs only on the Amiga 1000, 2000, and 3000,
with or without the 68040 board. If you want the program, I think it
appeared on Fish Disk 198.  8-)

Ali Ozer, ali@score.stanford.edu, decwrl!rocky.stanford.edu!ali