SpeedBar Button input doc

Have a question about our Software Developer Kit? Ask them here.
Post Reply
User avatar
tbreeden
Posts: 160
Joined: Sat Jun 18, 2011 12:57 am
Location: Charlottesville, VA, USA
Contact:

SpeedBar Button input doc

Post by tbreeden »

There seems to be some confusion about how to get the speedbar input.

I see that the SDK Reaction example for speedbar reads the code to get the
button that generated a WMHI_GADGETUP on the speedbar obtained by
a call to handle input method.

This is not mentioned in the AutoDocs for speedbar_cl (53.20), but experiment
shows that it does contain the id assigned to the "button" in the call to
AllocSpeedButtonNode() - not just the index from 0 in the speedbar.

Probably already taken care of in the to-be-released SDK, but otherwise it
should be documented or forbidden.

Tom
User avatar
trixie
Posts: 409
Joined: Thu Jun 30, 2011 2:54 pm
Location: Czech Republic

Re: SpeedBar Button input doc

Post by trixie »

@tbreeden

To handle speedbar.gadget input, I enum a set of button IDs and put them in SBNA_UserData when I AllocSpeedButtonNode() the respective button's node. When I receive an IDCMP_GADGETUP from the speedbar, I switch() the code and compare against the IDs. Always worked, been using this for years.
The Rear Window blog

AmigaOne X5000 @ 2GHz / 4GB RAM / Radeon RX 560 / ESI Juli@ / AmigaOS 4.1 Final Edition
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
User avatar
tbreeden
Posts: 160
Joined: Sat Jun 18, 2011 12:57 am
Location: Charlottesville, VA, USA
Contact:

Re: SpeedBar Button input doc

Post by tbreeden »

trixie wrote: To handle speedbar.gadget input, I enum a set of button IDs and put them in SBNA_UserData when I AllocSpeedButtonNode() the respective button's node. When I receive an IDCMP_GADGETUP from the speedbar, I switch() the code and compare against the IDs. Always worked, been using this for years.
Yes, that definitely will work, but it does not appear that it is necessary to put the IDs into SBNA_UserData. Since the ID is a parameter to AllocSpeedButtonNode(), it must be stored somewhere in the node, because it will be in the code after a GadgetUp without you having to put it anywhere. SBNA_UserData could probably be used for something else if you needed it.

The AutoDocs don't make that clear though.

Tom
User avatar
trixie
Posts: 409
Joined: Thu Jun 30, 2011 2:54 pm
Location: Czech Republic

Re: SpeedBar Button input doc

Post by trixie »

@tbreeden
tbreeden wrote: it does not appear that it is necessary to put the IDs into SBNA_UserData. Since the ID is a parameter to AllocSpeedButtonNode(), it must be stored somewhere in the node, because it will be in the code after a GadgetUp without you having to put it anywhere. SBNA_UserData could probably be used for something else if you needed it.

The AutoDocs don't make that clear though.
You are right - currently, the button ID is stored in the particular node's priority field (which is a clear hack and misuse of the node datastructure). The speedbar autodoc mentions this fact, and also adds that this may change in the future. This is probably why some of the available ReAction examples also store the ID in the userdata field. It is more future-proof to retrieve the ID from the userdata field than from the node's priority field.
The Rear Window blog

AmigaOne X5000 @ 2GHz / 4GB RAM / Radeon RX 560 / ESI Juli@ / AmigaOS 4.1 Final Edition
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
Post Reply