Mutual Exclude
13 messages in this thread
Can anyone help me write a routine that will correctly handle mutually
exclusive gadgets. I followed the instruction in the RKM:Libraries
manual, but to no avail.
My gadgets are hit-select with the GACT_IMMEDIATE flag set and I am doing
my gadget manipulations on receiving a IDCMP_GADGETDOWN message. I am
using bitwise ANDs and ORs etc. to set and clear the GFLG_SELECTED flag
and this appears to work correctly, but maybe there is a better way.
If anyone has a small snippet of code demonstating how to handle mutually
exclusive gadgets, I would appreciate it.
Thanks,
Bill
The best bet is to use GadTools gadgets. The MX gadgets in there work
right, without any hassle.
One question concerning the MX Gadgets. I have been playing around with
them and I can't really figure out what in the heck to do. My problem is
when you have say a MX gadget with 4 elements … and you run the program
and select one of the elements. What all do you have to do code wise?
It appears that the element that I select is updated then thats it. I have
tried doing the GT_SetGadgetAttrs() but still nothing is working right.
Where am I missing the big flick at? What do you have to do to properly
user MX gadgets?
I'm not sure what you mean. Do you mean GadTools MX gadgets, or the old
ones that don't really work. (There may be some way to get them to work, I
don't know.)
With GadTools MX gadgets, I just look at the code to see which of the
elements was hit.
I am talking about the new GadTools MX gadgets. I know all that you do is
check out the Code field to see which one is active but here is my problem.
I got a window setup to be sorta like a requestor and I have a bunch of MX
gadgets in it. What happens when I hit one of the items in a MX gadget is
… the item is highlighted and then thats it! The blasted thing just sits
there and looks stupid. I can not change to any other setting or anything
else in that window. I dont know what I am missing. I have been out of it
for a while on Amiga specific stuff and more so on the new 2.0 items. What
I am doing when I recieve the IDCMP message is I case down to the
particular gadget and then do a GT_SetGadgetAttrs with the GTMX_Active
(message->Code) etc.. and then break out. There isn't a whole heckuva lot
in the RKM's on the new gadget stuff to allow me to properly nuke the MX
one's out. It you have any code examples that I can leach on I would
appreciate it.
In a nut shell … I am lost after I recieve the IDCMP message with the MX
info etc.. What next?
If I'm understanding you correctly, you're trying to set a MX gadget to
whatever setting the system has just told you it was set to. There's no
need to do that.
Also, are you GT_ReplyIMsg'ing after you've looked at the message? (For
that matter, are you using GT_GetIMsg instead of GetMsg?)
I have everything working now. Yeah, I was using GT_GetMsg vice the
standard GetMsg. I was getting confused on how to play with the new
gadgets. What I wanted to do was set the slider gadgets and MX gadgets to
pre-define (or whatever my programs current) levels when I opened up a
window that had them in it … something for stuff like palette editors
etc..
I figured out that I didn't need to do an update on the gadgets once I did
something to them in the program. My debugger was showing me they were
being updated by the system and I didn't have to worry about that.
Well I couldn't see the forest for the trees! I finally decided to put it
thru the old debugger and it stuck out like a sore thumb. What I totally
forgot to do was stay withing my second IDCMP loop until I was done with
the second window. I would catch the closewindow just fine if I did it
first because that was only trip one thru the loop … well try hitting a
gadget twice … forget it! I ended up in the IDCMP loop for my original
window. I checked everything out after I fixed that boo boo and it works
great. You are right, those MX gadgets are a zillion times better than the
old way of doing things. Yeap and Code field had the ordinal number etc..
just like it should have. At first I thought I might have been passing the
wrong address to GT_SetGadgetAttrs() but I had that right. All is well.
Thanks for the help.
Although you have already resolved the issue, one thing that I would
recommend strongly is that you have only ONE IDCMP loop in your entire
program. This makes the code much more maintainable in the long run and
avoids repeats of bugs where you only change one place…
True … but what the heck, I never take the easy way out!
Strange Code -r- Us
John,
I have been following this thread on MX type gadgets and was wondering if
you knew of some example code that would demonstrate the proper method of
implementing Mutual Exclude gadgets (not the MX variety). I have followed
the method described in RKM:Libraries to no avail. I think it may be that
I am not removing and readding the gadgets correctly.
Any help you or anyone else can give will be greatly appreciated.
Bill
I don't have a simple example right handy, but I can certainly help you
locate the problem with the RKM example. The key is to use a rendering
mode which complete rewrites the area in which it lives no matter what is
currently there. For this, the simplest is to use a Image structure for
both the selected and non-selected state. If you fire a copy of the code
to me, I will be happy to look at it.
John,
Thanks! I have been messing with the code a bit to see what works (so far
nothing 🙂 so I'll clean it up a tad and get it back to what I think
should work and send you a copy. I really appreciate this.
Bill