Bug with Window gadgets? (Solved)

This forum is for general developer support questions.
Post Reply
User avatar
ktadd
Posts: 47
Joined: Wed Nov 09, 2011 5:50 am

Bug with Window gadgets? (Solved)

Post 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,
Last edited by ktadd on Thu Apr 07, 2022 6:35 pm, edited 1 time in total.
Kevin - X1000 first contact / uA1
User avatar
thomasrapp
Posts: 306
Joined: Sat Jun 18, 2011 11:22 pm

Re: Bug with Window gadgets?

Post 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.
User avatar
ktadd
Posts: 47
Joined: Wed Nov 09, 2011 5:50 am

Re: Bug with Window gadgets?

Post by ktadd »

Bug fixed. Thanks Thomas!
Kevin - X1000 first contact / uA1
Post Reply