Page 1 of 1

Bug with Window gadgets? (Solved)

Posted: Thu Apr 07, 2022 8:29 am
by ktadd
Two questions, (OS4 release 4.1 Final Update 2 with Enhancer 2.1)

1. Is it required to remove your gadget or gadget list before changing gadget attributes and then add them back after the change?
IIntuition->RemoveGList(windows[WID_MAIN], gadgets[GID_MAIN], -1);
IIntuition->AddGList(windows[WID_MAIN], gadgets[GID_MAIN], 0, -1, NULL);


2. When I do the above I get problem of the Front to back window gadget swaping places with the Resize gadget. Any idea why this happens?

I have some code that creates a window with a bunch of gadgets. When the window first opens the top right Window barder gadgets in the order they should be in. Iconify gadet first, followed by the Resize gadget, then the Front to back gadget frutherst to the right. When I remove all window gadgets, then add them back the Front to back gadget switches places with the Resize gadget, so the Resize gadget is now the right most gadget.

I did a test where I create the window, then remove the gadgets and re-attach the gadgets and the problem occurs. The code looks like this:

windows[WID_MAIN] = (struct Window *) RA_OpenWindow(objects[OID_MAIN]);
display_info_request(objects[OID_MAIN], REQIMAGE_ERROR, "PAUSING PROGRAM!!.\n\n");
IIntuition->RemoveGList(windows[WID_MAIN], gadgets[GID_MAIN], -1);
IIntuition->AddGList(windows[WID_MAIN], gadgets[GID_MAIN], 0, -1, NULL);
display_info_request(objects[OID_MAIN], REQIMAGE_ERROR, "PAUSING PROGRAM!!.\n\n");

When the first requester appears, the gadgets are in the order they should be in.
When the second requester appears, the Front/Back gadget has switched places with the Resize gadget.

Here is my Window structure:
objects[OID_MAIN] = WindowObject,
WA_Title, PROG_NAME PROG_VERSION,
WA_DragBar, TRUE,
WA_CloseGadget, TRUE,
WA_SizeGadget, TRUE,
WA_DepthGadget, TRUE,
WA_NewLookMenus, TRUE,
WA_Activate, TRUE,
WINDOW_IconifyGadget, TRUE,
WINDOW_AppPort, AppPort,
WINDOW_Position, WPOS_CENTERSCREEN,
WINDOW_LockHeight, TRUE,
WINDOW_NewMenu, mynewmenu,
WINDOW_GadgetHelp, cmds.hint_mode,
WINDOW_HintInfo, &mytips,
WINDOW_ParentGroup, gadgets[GID_MAIN] = (struct Gadget *)VLayoutObject,
LAYOUT_SpaceOuter, TRUE,
LAYOUT_SpaceInner, TRUE,
LAYOUT_DeferLayout, TRUE,
LAYOUT_AddChild,SpaceObject,End,

Re: Bug with Window gadgets?

Posted: Thu Apr 07, 2022 5:49 pm
by thomasrapp
You must never call RemoveGList or AddGList in a ReAction context. ReAction gadgets belong to ReAction. You may not touch their linkage. The only way to remove a gadget from the GUI is the LAYOUT_RemoveChild attribute of layout.gadget.

You can change gadget attributes using SetGadgetAttrs or, if the gadget does not refresh itself, using SetAttrs followed by RefreshGList.

If your change implies a change of the layout, for example the window size, then you might need to call WM_RETHINK instead of RefreshGList.

Re: Bug with Window gadgets?

Posted: Thu Apr 07, 2022 6:34 pm
by ktadd
Bug fixed. Thanks Thomas!