[comp.sys.amiga.tech] String Gadgets

chas@gtss.UUCP (Charles Cleveland) (04/13/88)

String gadgets are de-selected by pressing return or clicking the mouse
elsewhere.  We can tell the system knows in both cases that the gadget
is de-selected because the cursor in it disappears.  If my string gadget
has RELVERIFY set I get a GADGETUP event when I deactivate the sucker by
pressing return, but not when I click the mouse elsewhere.

Is there some reason for this?  Is there SOME combination of flags that
will get Intuition to send me some (not necessarily GADGETUP, though
that would be nice) event when a string gadget is de-selected by mouse-
click?

Oh, and yes I know that string gadgets are broken.  I just don't think
I know all the ways they are broken yet.  Anybody have a canonical list?
-- 
-Life would be so much easier if we could just look at the source code.-

Charles Cleveland    Georgia Tech School of Physics    Atlanta, GA 30332
UUCP: ...!gatech!gtss!chas         INTERNET:  chas@ss.physics.gatech.edu

jimm@amiga.UUCP (Jim Mackraz) (04/14/88)

In article <239@gtss.UUCP> chas@gtss.UUCP (Charles Cleveland) writes:
)String gadgets are de-selected by pressing return or clicking the mouse
)elsewhere.  We can tell the system knows in both cases that the gadget
)is de-selected because the cursor in it disappears.  If my string gadget
)has RELVERIFY set I get a GADGETUP event when I deactivate the sucker by
)pressing return, but not when I click the mouse elsewhere.

Well known problem.  People have posted ways that this can be
handled by little checks scattered about your event processing loop
(when you think the gadget is active, and you get a message that
indicates the contrary (or the SELECTED flag is cleared), you process
the routine you want to do upon gadget termination).

)
)Is there some reason for this?  Is there SOME combination of flags that
)will get Intuition to send me some (not necessarily GADGETUP, though
)that would be nice) event when a string gadget is de-selected by mouse-
)click?
Reason?  I think the intention was that the user would only hit
return if he was SURE and wanted action right now, similar in Zen
to the RELVERIFY Boolean gadget, but that doesn't fly too well.  It's not
clear how far we can go in fixing this: many file requesters take
action when they hear about that RETURN, and sending them ENDGADGET
when the user isn't really done would be a problem.  We probably should
have used the Code field of the message to tell the termination
condition.  I fear that we can't fix programs in the field automagically
on this one.  We will certainly provide a method for future programs
to handle this, it's too bad we can't do more, now.

You basically have to listen to almost every other message class, and
there are still some edge cases (like window dragging) when you
still won't hear.  Poll that SELECTED flag (on INTUITICKS, for example).

)Oh, and yes I know that string gadgets are broken.  I just don't think
)I know all the ways they are broken yet.  Anybody have a canonical list?
All I can do is fix 'em.  Harriet Tolly's articles in Amazing Computing
had a lot of stuff *I* didn't know (and *I* broke 'em in the second place).

)-Life would be so much easier if we could just look at the source code.-
In this case, I don't think so.  You might have just sold your Amiga.
Anyway, it's been rewritten for V1.4 (this week) although that won't
help you much for a while.  But gee, it sure is great in the lab ;&)

)Charles Cleveland    Georgia Tech School of Physics    Atlanta, GA 30332
sorry charlie.

	jimm
	I and I
-- 
	Jim Mackraz, I and I Computing	  
	amiga!jimm	BIX:jmackraz
Opinions are my own.  Comments regarding the Amiga operating system, and
all others, are NOT to be taken as Commodore official policy.

shf@well.UUCP (Stuart H. Ferguson) (04/15/88)

The question is about the behavior of string gadgets -- why don't you always
get a gadgetup message when the string becomes deactive, no matter if you 
pressed return or clicked elsewhere?

Actually, the behavior is consistent, at least in my understading, with the
behavior of boolean gadgets with the GADGIMMEDIATE and RELVERIFY flags set.
Note that if you have a boolean gadget with these flags both set, you will
get a message immediately when the user clicks on the gadget, and you will get
another when the user releases the mouse button IFF the pointer is still
over the gadget.  If the user pulls the mouse pointer off the gadget while 
holding down the select button, the gadget will de-select and you will NOT
get a GADGETUP message.

This is exactly analagous to the behavior of string gadgets with these flags 
set.  When the user selects the gadget, you will get a GADGETDOWN message,
and you will get a GADGETUP message IFF the user presses return.  Clicking
elsewhere is like pulling the mouse pointer off the boolean gadget before
relasing the button.

If you need to know when the user is through with the string gadget, just
look for any other message coming from the same {Window|Requester}.  As soon
as one comes, you know the user is done with the gadget, since you can't
get another message until he clicks someplace else or presses return.
-- 
		Stuart Ferguson		(shf@well.UUCP)
		Action by HAVOC		(shf@Solar.Stanford.EDU)

chas@gtss.UUCP (Charles Cleveland) (04/15/88)

In article <2035@amiga.UUCP> jimm@amiga.UUCP (Jim Mackraz) writes:

)In article <239@gtss.UUCP> chas@gtss.UUCP (Charles Cleveland) writes:
))String gadgets are de-selected by pressing return or clicking the mouse
))elsewhere.  We can tell the system knows in both cases that the gadget
))is de-selected because the cursor in it disappears.  If my string gadget
))has RELVERIFY set I get a GADGETUP event when I deactivate the sucker by
))pressing return, but not when I click the mouse elsewhere.

).... Poll that SELECTED flag (on INTUITICKS, for example).

This was what I had in mind to do if no happier answer came in.  Its really
not so bad since I can set GADGIMMEDIATE on the string gadgets I'm worried
about and thus detect when one has been selected and therefore only
monitor INTUITICKS while one of the string gadgets I care about is active,
thereby reducing polling to a minimum.

)All I can do is fix 'em.  Harriet Tolly's articles in Amazing Computing

Thanks for the reference to Tolly.

))-Life would be so much easier if we could just look at the source code.-
)In this case, I don't think so.  You might have just sold your Amiga.

Too many of those originally responsible for developing the Amiga have
responded in more or less those words to that line in my .signature, while
I had intended it only as a general metaphysical remark.  That does it!
I'm changing my .signature to something more appropriate to the state
of documentation everywhere.
			--------
"Wouldn't the sentence 'I want to put a hyphen between the words Fish
and And and And and Chips in my Fish-And-Chips sign' have been clearer
if quotation marks had been placed before Fish, and between Fish and
and, and and and And, and And and and, and and and And, and And and
and, and and and Chips, as well as after Chips?"
-- 
Charles Cleveland    Georgia Tech School of Physics    Atlanta, GA 30332
UUCP: ...!gatech!gtss!chas         INTERNET:  chas@ss.physics.gatech.edu

chas@gtss.UUCP (Charles Cleveland) (04/15/88)

In article <5698@well.UUCP> shf@well.UUCP (Stuart H. Ferguson) writes:
)If you need to know when the user is through with the string gadget, just
)look for any other message coming from the same {Window|Requester}.  As soon
)as one comes, you know the user is done with the gadget, since you can't
)get another message until he clicks someplace else or presses return.

Actually, I even want to know when the gadget is de-selected if the user
clicks outside of any gadget, or in another window.  I have a window with
a lot of string gadgets in which numbers are entered.  Some of the numbers
can be recalculated depending on values in other fields.  If a user can
enter a number in a field and then just click outside any gadget (to get
rid of the cursor) without letting the program know that a value has been
changed, he could make it appear that results followed from a set of
input values with which they were in fact inconsistent.  An unethical
person could use this 'feature' fraudulently.

Anyway the problem is sol-ved.  I have outlined my solution in a followup
to a followup by jimm.
			--------
"Wouldn't the sentence 'I want to put a hyphen between the words Fish
and And and And and Chips in my Fish-And-Chips sign' have been clearer
if quotation marks had been placed before Fish, and between Fish and
and, and and and And, and And and and, and and and And, and And and
and, and and and Chips, as well as after Chips?"
-- 
Charles Cleveland    Georgia Tech School of Physics    Atlanta, GA 30332
UUCP: ...!gatech!gtss!chas         INTERNET:  chas@ss.physics.gatech.edu

pds@quintus.UUCP (Peter Schachte) (04/16/88)

In article <5698@well.UUCP>, shf@well.UUCP (Stuart H. Ferguson) writes:
> If you need to know when the user is through with the string gadget, just
> look for any other message coming from the same {Window|Requester}.  As soon
> as one comes, you know the user is done with the gadget, since you can't
> get another message until he clicks someplace else or presses return.

Not so.  You may get a message to refresh your window (REFRESHWINDOW?
I don't have my manuals here.)  This doesn't mean that he's done with
the gadget.  Or you could get a MENU-related message.  You have to be
somewhat selective.
-- 
-Peter Schachte
pds@quintus.uucp
...!sun!quintus!pds

dg2l+@andrew.cmu.edu (Douglas Phillip Ghormley) (01/24/89)

I wrote a program that uses a string gadget, but when I activate the gadget so I
can type in it, no cursor appears.  How do I put one there (and have it respond
to the arrow keys)?

-Doug Ghormley
 dg2l@andrew.cmu.edu

cmcmanis%pepper@Sun.COM (Chuck McManis) (01/25/89)

In article dg2l+@andrew.cmu.edu (Douglas Phillip Ghormley) writes:
-> I wrote a program that uses a string gadget, but when I activate the 
-> gadget so I can type in it, no cursor appears.  How do I put one there 
-> (and have it respond to the arrow keys)?

Try the GADGHCOMP flag, if you don't set it you get an invisible cursor.


--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.

shimoda@infohh.rmi.de (Markus Schmidt) (01/27/89)

By the way. Does anyone have a method to make ActivateGadget mor
reliable. It seems to fail in 10% of the cases. A Delay(5) after 
it seems to make a little improvement, is there anything better?


.-----------------------------------------------------------------.
|  shimoda@rmi.de       `---'   The last remaining adventure      |
|  shimoda@gopnbg.UUCP  |O o|   since there are no more tigers:   |
|                       ==Y==   Doublebuffered async. I/O       _ |
|----------------------- `U' ------------------------------  _ // |
|  Good terminalpackages     begin with A: AmigaCall, A-Ta.. \//  |
`-----------------------------------------------------------------'

papa@pollux.usc.edu (Marco Papa) (01/29/89)

In article <483@infohh.rmi.de> shimoda@infohh.rmi.de (Markus Schmidt) writes:
>By the way. Does anyone have a method to make ActivateGadget mor
>reliable. It seems to fail in 10% of the cases. A Delay(5) after 
>it seems to make a little improvement, is there anything better?

I use something like this (this assumes a requester, and I cut out the 
usual loop for GetMsg, the Wait(), etc.., but should give you the idea):

mes = (struct IntuiMessage *) GetMsg(window->UserPort);

class = mes->Class;

if (class == REQSET) ActivateGadget(&gadget, window, &req);

Seems to work all the time.

-- Marco Papa 'Doc'
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
uucp:...!pollux!papa       BIX:papa       ARPAnet:pollux!papa@oberon.usc.edu
 "There's Alpha, Beta, Gamma and Diga!" -- Leo Schwab [quoting Rick Unland]
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

aaron@madnix.UUCP (Aaron Avery) (01/30/89)

In article <483@infohh.rmi.de> shimoda@infohh.rmi.de (Markus Schmidt) writes:
>By the way. Does anyone have a method to make ActivateGadget more
>reliable. It seems to fail in 10% of the cases. A Delay(5) after 
>it seems to make a little improvement, is there anything better?

Well, I can only say a few things I've observed about ActivateGadget which may
or may not help. I've found that it sometimes works if the window is _not_
activated when you call it, but usually doesn't. The other big one is that if
you call it to activate two different gadgets in a row (like multiple events
queued up to your UserPort telling you to activate multiple gadgets), only the
first one will take effect. Note that theses are also possibly just guesses,
as they're not confirmed to be fact. Hope that helps some.

-- 
Aaron Avery, ASDG Inc.         "A mime is a terrible thing to waste."
                                                             -- Robin Williams
ARPA: madnix!aaron@cs.wisc.edu   {uunet|ncoast}!marque!
UUCP:   {harvard|rutgers|ucbvax}!uwvax!astroatc!nicmad!madnix!aaron

jgary@ms.uky.edu (James E. Gary) (01/31/89)

I find it useful to wait for an ACTIVEWINDOW message before ActivateGadget()
if I the window has just been opened. Apparently ActivateGadget() doesn't
work at all if the window it is in is not active. If you are trying to
activate the gadget immediately after opening the window, then you may get
lucky depending on how busy the system is, and the window may get activated
before your ActivateGadget() call, but you can't count on it. Best bet is
to request an active window before messing with the gadget.

jimm@amiga.UUCP (Jim Mackraz) (02/01/89)

In article <10999@s.ms.uky.edu> jgary@ms.uky.edu (James E. Gary) writes:
)
)I find it useful to wait for an ACTIVEWINDOW message before ActivateGadget()
)if I the window has just been opened. Apparently ActivateGadget() doesn't
)work at all if the window it is in is not active. If you are trying to
)activate the gadget immediately after opening the window, then you may get
)lucky depending on how busy the system is, and the window may get activated
)before your ActivateGadget() call, but you can't count on it. Best bet is
)to request an active window before messing with the gadget.

That's correct, and as described in the Intuition V1.2 Enhancer Document.

Also, if the gadget is in a Requester you are putting up, wait for the
REQSET message before calling ActivateGadget().

	jimm

Using Delay() for this is wrong, and icky, and unecessary.

-- 
Jim Mackraz, I and I Computing	   	"Like you said when we crawled down
{cbmvax,well,oliveb}!amiga!jimm          from the trees: We're in transition."
							- Gang of Four
Opinions are my own.  Comments are not to be taken as Commodore official policy.

Sylvain@speedy.CAM.ORG (Sylvain Tremblay) (06/27/90)

>In article <1990Jun25.212817.9615@cunixf.cc.columbia.edu> will@cunixf.cc.columbia.edu (William Chou) writes:
>
>   When you have alot of string gadgets to write data to, how do you
>	auto-activate each one after the user finishes with the previous
>	string gadget?  Is there a way to poll for certain keys, such as
>	the cursor keys, when using string gadgets?

The only thing you can do WITHOUT an input handler is waiting a GADGETUP
message.  This message is sent by intuition whenever a user presses RETURN
in a string gadget.  If you want to monitor the cursor keys, you'll have to
write an input handler.

OR

You can wait for 2.0.  In that version of the OS, I think that there are
functions that let you set up some keys with string gadgets that, when pressed,
call a certain function.

--
Sylvain
                                                                   __
+-----------------------------------------------------------------///------+
|  Sylvain Tremblay        INTERNET: Sylvain@speedy.CAM.ORG  __  ///   /|  |
|  Montreal, Qc, Canada         CIS: 71640,666               \\\///  #  |  |
|  (514) 256-3779                or: 71640.666@compuserve.com \XX/     _|_ |
+--------------------------------------------------------------------------+