Gadgets may be added to a window or requester when the window or requester is opened, or they may be added later. To add the gadgets when a window is opened, use the wa_gadgets tag with the openwindowtaglist() call. this technique is demonstrated in the example above. For a requester, set the reqgadget field in the requester structure to point to the first gadget in the list. To add or remove gadgets in a window or requester that is already open, use addglist() or removeglist(). these functions operate on gadgets arranged in a list. A gadget list is linked together by the nextgadget field of the Gadget structure (see the description of the gadget structure later in this chapter). addglist() adds a gadget list that you specify to the existing gadget list of a window or requester: UWORD AddGList( struct Window *window, struct Gadget *agadget, unsigned long position, long numGad, struct Requester *requester ); Up to numGad gadgets will be added from the gadget list you specify beginning with agadget. The position argument determines where your gadgets will be placed in the existing list of gadgets for the window or requester. Use (~0) to add your gadget list to the end of the window or requester's gadget list. This function returns the actual position where your gadgets are added in the existing list. To remove gadgets from a window or requester use removeglist(): UWORD RemoveGList( struct Window *remPtr, struct Gadget *agadget, long numGad ); This function removes up to numGad gadgets from a window or requester, beginning with the specified one. Starting with V37, if one of the gadgets that is being removed is the active gadget, this routine will wait for the user to release the mouse button before deactivating and removing the gadget. This function returns the former position of the removed gadget or -1 if the specified gadget was not found. The gadget structure should never be directly modified after it has been added to a window or requester. To modify a gadget, first remove it with removeglist(), modify the structure as needed, and then add the gadget back to the system with addglist(). finally, refresh the gadget imagery with refreshglist(). (see the section on "gadget refreshing" below for more information.) Some attributes of a gadget may be modified through special Intuition functions that perform the modification. When using such functions it is not necessary to remove, add or refresh the gadget. These functions, such as newmodifyprop(), ongadget() and offgadget(), are described later in this chapter.