OM_NOTIFY in a gadget class

3 posts / 0 new
Last post
trixie
trixie's picture
Offline
Last seen: 5 months 2 weeks ago
Joined: 2011-02-03 13:58
OM_NOTIFY in a gadget class

I'm updating an existing BOOPSI gadget to support the OM_NOTIFY method on the GA_Selected attribute. The idea is that the gadget (a checkbox kind) can act as a "master" gadget that sets the value of its subordinate gadgets. Thus, when the master's GA_Selected is set to TRUE/FALSE, the subordinate gadgets will receive an OM_NOTIFY to set their value to that of the master. For this to work, the master checkbox adds the subordinate checkboxes to its broadcast list via OM_ADDMEMBER.

In the "rkrmmodelclass.c" example in the Amiga Dev Wiki, the actual execution of the OM_NOTIFY method is delegated to the superclass (model.class), which informs the gadgets on the rkrmmodel.class's broadcast list.

OK, that's the model class kind. But what I'm not sure about is how gadgetclass subclasses are supposed to act. Should the OM_NOTIFY be handled by my checkbox gadget, or should I pass it on to gadgetclass by calling IDoSuperMethod()?

thomas
thomas's picture
Offline
Last seen: 1 week 12 hours ago
Joined: 2011-05-16 14:23
Re: OM_NOTIFY in a gadget class

Gadgets don't have a distribution list. OM_ADDMEMBER has no function for gadgets, unless you implement it. A BOOPSI class only has a built-in node, but not a built-in list. So you can add a BOOPSI object to a list by calling its OM_ADDTAIL method. But if you want a list, you have to add a struct List to your instance data and implement the OM_ADDMEMBER method, which calls the member's OM_ADDTAIL method with a pointer to your list. But as you can imagine, adding an object to a random list does not have any substance.

To notify another object about changes, you call the OM_NOTIFY method of your super class. The super class then calls the OM_UPDATE method of its ICA_TARGET with the data you provided.

If you want to forward the notification to multiple objects, you have to make a modelclass object, add all the targets to the model using OM_ADDMEMBER and then set the ICA_TARGET of your super class to the model.

Find attached an example with checkboxes.

File attachments: 

AttachmentSize
Plain text icon model.c.txt7.69 KB
trixie
trixie's picture
Offline
Last seen: 5 months 2 weeks ago
Joined: 2011-02-03 13:58
Re: OM_NOTIFY in a gadget class

@thomas

Thank you Thomas, as helpful and informative as always! The wiki documentation on OM_ADDMEMBER is a bit hazy. For example, in one place it says

... to ask the BOOPSI object myobject to add the object addobject to its personal list:

IIntuition->IDoMethod(myobject, OM_ADDMEMBER, addobject);

and later in the text

The OM_ADDMEMBER method is defined by rootclass. It adds one BOOPSI object to the personal list of another BOOPSI object. It is up to the BOOPSI object's class to determine the purpose of the objects in the list.

which suggests that the OM_ADDMEMBER is a general method applicable to all BOOPSI classes. It didn't occur to me that gadgetclass doesn't implement a "personal list" to add objects to.

AmigaOne X5000-020 / 2GB RAM / Sapphire Pulse Radeon RX 560 / AmigaOS 4.1 Final Edition Update 2

Log in or register to post comments