#IDCMP IAddress
8 messages in this thread
I had an interesting little experience with the IDCMP Port. I was using
IDCMP through a window to read clicks on gadgets. I would identify the gadgets
clicked by comparing them to the address found in IAddress of the IntuiMessage
structure. This worked perfectly as long as I was only getting I/O from
gadgets.
When I installed a menu strip to my program, I got a strange bug that would
randomly give me an Illegal Address Guru when I would select the menu. I found
that the bug was caused by my treating IAddress as a Gadget pointer even for a
MENUPICK. But the reason it was a seemingly random bug was that IAddress would,
most of the time, hold a legal if useless address. Mostly it was 0x00000000.
Sometimes it was 0xffff0000. These addresses I could treat as Gadget pointers
as long as I didn't actually do anything but read from them, and therefor the
program wouldn't crash.
But occasionally, the value returned in IAddress was 0x00000001 or
0x00000003, which would immediately Guru when I tried to cast it to a Gadget
pointer. This was, of course, because an address is completely illegal to the
68000 processor.
My question is, is the value returned in IAddress SUPPOSED to mean anything
when the IDCMP message isn't a gadget? Specifically MENUPICK and RAWKEY and
CLOSEWINDOW?
Thanks!
-Mike
IAddress is currently only defined for gadget events.
Michael,
You should set the GadgetID field of each gadget to something unique, and
then check that field to see which gadget got hit.
I use a neat trick whenever I have gadgets that I want to cause a jmp (I use
assembly language). I set the ID of every "jump" gadget to the same value, and
then put the address of the jump in the UserData (or whatever its called)
field. If I detect the ID value, I jump to the UserData address. —Mike
Mike,
Getting the GadgetID was what was giving me trouble in the first place.
Whenever IDCMP got a message, I would load IAddress into a Gadget pointer and
then grab the ID by doing 'id = gadgptr->GadgetID. When I started using menus,
IAddress would point to some unknown area and when it got cast to a Gadget
structure pointer, GadgetID would be some wierd number from Hell. Now I just
grab GadgetID when Class is GADGETUP or GADGETDOWN.
By the way, my GadgetID *is* set so I know which of three identical areas of
my program I clicked in. That does cut the search down by a third.
-Mike
Mike,
You should only be looking at the GadgetID if the message->Class is either
GADGETUP or GADGETDOWN. Any other IDCMP class will _not_ be pointing to a
struct Gadget in the message->IAddress element. Always check the class of the
message first, and process accordingly. Much safer.
Hope this helps….BobR
Bob is correct. When a menu event is specified, IAddress points to the menu
item structure, and when it is a gadget event it points to the gadget
structure.
IAddress does NOT point to a menu item structure when you get a menu event.
You need to use the ItemAddress() procedure on the IntuiMessage's Code
field.
Right you are Martin. IAddress is needed when doing a dead key convert ,
and probably for other things as well. In any case, such structures are
context sensitive.