Forum unknown
· Programming
#Help w/Gadgets in C
9 messages in this thread
hello …. first time i've logged on in a long time.
Need help w/INTUITION problem.
My program has several gadgets, of BOOLEAN type, which are Toggle types. They
work fine.
However, I need to change the on/off state, sometimes, under program control,
rather than when user clicks on them.
My code for this merely alters the gadget->Flags |= SELECTED bit, then calls
RefreshGadgets().
What I see is that the rendering of the gadgets doesn't track what I do with
the SELECTED bit.
In fact, successive calls to RefreshGadgets() without changing the FLAGS word
causes the graphics rendering to change between three different appearances.
Any ideas?
Steve Childress. 73007,350 plink:OPS274 USENET:
..!wlbr!etn-rad!steve
Steve,
Yes… sounds like these are "toggle-selected/text-rendered" gadgets
right?
As it turns out the system doesn't like/understand such an arrangement when
it
comes to 'deselecting' them via program control ( I banged my head on that
wall
for a long time). There _is_ a way to get around the problem ( I don't
recall
off-hand what it is) and I think there is a file here in LIB 10 that shows
an example of how to do it (sorry, can't remember the name of the file
either).
The other way is to use 'Image-rendered' gadgets… these seem to work
fine under program control for selecting/de-selecting. ( sorry about all the
line noise )
Maybe someone else remembers the name of that file I speak of and can
jump in here with it.
Keith
Steve,
Yes… sounds like these are "toggle-selected/text-rendered" gadgets
right?
As it turns out the system doesn't like/understand such an arrangement when
it
comes to 'deselecting' them via program control ( I banged my head on that
wall
for a long time). There _is_ a way to get around the problem ( I don't
recall
off-hand what it is) and I think there is a file here in LIB 10 that shows
an example of how to do it (sorry, can't remember the name of the file
either).
The other way is to use 'Image-rendered' gadgets… these seem to work
fine under program control for selecting/de-selecting. ( sorry about all the
line noise )
Maybe someone else remembers the name of that file I speak of and can
jump in here with it.
Keith
Yah, I ran up against that problem a few months ago with my Remind program.
What's happening, if I recall correctly, is that gadget selecting is handled
pretty simplemindedly. When you do a RefreshGadgets(), Intuition checks to
see if the gadget is selected. Aha, says Intuition, here's a selected
gadget… so it complements the gadget. Now, if your program deselects the
gadget and you call RefreshGadgets() again, the gadget ISN'T selected… so
Intuition does nothing, the gadget stays inverted, and it's out of sync.
Conversely, if you call RefreshGadgets() with some gadgets still selected,
Intuition says "Aha…" again, and the SELECTED gadgets get turned OFF
visually.
There are a couple of approaches to this. First, use RefreshGList() instead
of RefreshGadgets(), and refresh ONLY the gadget whose state you want to
change. In combination with that, have the gadget SELECTED any time you want
to CHANGE its state. So, the gadget is off? Set SELECTED and call
RefreshGList(). Need to turn it off? Call RefreshGList() FIRST to
uncomplement the gadget, THEN clear the SELECTED bit. Some people recommend
calling RefreshGList() again after clearing the bit.
A cleaner approach is to use alternate-image gadgets, which should always
stay in sync.
There is a trick for supplying a dummy image to text/border rendered gadgets
so they can be deghosted. I don't recall trying, but I wouldn't be
<continued>
Yah, I ran up against that problem a few months ago with my Remind program.
What's happening, if I recall correctly, is that gadget selecting is handled
pretty simplemindedly. When you do a RefreshGadgets(), Intuition checks to
see if the gadget is selected. Aha, says Intuition, here's a selected
gadget… so it complements the gadget. Now, if your program deselects the
gadget and you call RefreshGadgets() again, the gadget ISN'T selected… so
Intuition does nothing, the gadget stays inverted, and it's out of sync.
Conversely, if you call RefreshGadgets() with some gadgets still selected,
Intuition says "Aha…" again, and the SELECTED gadgets get turned OFF
visually.
There are a couple of approaches to this. First, use RefreshGList() instead
of RefreshGadgets(), and refresh ONLY the gadget whose state you want to
change. In combination with that, have the gadget SELECTED any time you want
to CHANGE its state. So, the gadget is off? Set SELECTED and call
RefreshGList(). Need to turn it off? Call RefreshGList() FIRST to
uncomplement the gadget, THEN clear the SELECTED bit. Some people recommend
calling RefreshGList() again after clearing the bit.
A cleaner approach is to use alternate-image gadgets, which should always
stay in sync.
There is a trick for supplying a dummy image to text/border rendered gadgets
so they can be deghosted. I don't recall trying, but I wouldn't be
<continued>
<continuation>
surprised if the same trick would work for the selection problem.
As Harriet Maybeck Tolly says, "Any type of manipulation of the SELECTED
flag, followed by calls to RefreshGadgets(), is tricky at best with non-Image
Gadgets." Amen. You might want to pick up some back issues of Amazing
Computing and read her tutorial on gadgets; it helped me a lot, and this very
issue is addressed. The issues are V2.3, V2.5, and V2.7. Booleans are
covered in V2.5.
Rick
<continuation>
surprised if the same trick would work for the selection problem.
As Harriet Maybeck Tolly says, "Any type of manipulation of the SELECTED
flag, followed by calls to RefreshGadgets(), is tricky at best with non-Image
Gadgets." Amen. You might want to pick up some back issues of Amazing
Computing and read her tutorial on gadgets; it helped me a lot, and this very
issue is addressed. The issues are V2.3, V2.5, and V2.7. Booleans are
covered in V2.5.
Rick
I seem to have some line noise in here. Sorry about the state of the messag{.
Personally, I think the easies method is to do RectFill for the gadget area
and then do a RefreshList for the gadget. Its easy and its fun.
-Martin Murray
I seem to have some line noise in here. Sorry about the state of the messag{.
Personally, I think the easies method is to do RectFill for the gadget area
and then do a RefreshList for the gadget. Its easy and its fun.
-Martin Murray