Discovered something interesting today:
In all my previous Amiga-specific coding (main loop, message handling, switch-case on gadget IDs), I’ve always used int32 code, and it worked fine for everything — until now.
While experimenting with speedbar.gadget, I noticed that code wasn’t matching any of my expected IDs. Instead of getting 1, 2, 3, 4, 5, 6 ., I got:
unknown button ID: 65536
unknown button ID: 131072
unknown button ID: 196608
unknown button ID: 262144
unknown button ID: 32760
unknown button ID: 393216
Turns out that SpeedBar.gadget encodes the button ID in the upper 16 bits of "int32 code", while WMHI_GADGETMASK (0xFFFF) filters the lower 16 bits of result. So unless you shift code >> 16, switch will never match.
For quick fix i manually shift the ID out of code:
if ((result & WMHI_GADGETMASK) == GID_SPEEDBAR)
{
uint32 buttonID = code >> 16;
switch (buttonID)
{
case SBID_NEW: // etc.
.....
But what i am wondering about now: should I always keep code value as int32 and just shift when needed (seems rare, and speedbar.gadget only specific), or should I make "code" as uint16 from the start to avoid this kind of surprise and hope int16 will bring no other issues instead ?:)