Hi,
I am trying to dynamically add objects to my Reaction Layout but without success.
I read
http://www.os4coding.net/forum/create-buttons-loop but I certainly missed something (I'm even worst on Reaction than I'm on MUI and Qt
)
I'm trying to dynamically add 3 buttons AFTER that the window is created
but it displays me only the 2 first fixed buttons
I tried too to DoMethod(win, WM_RETHINK); after the setAttrs(LAYOUT_AddChild)...
I cross-posted this question on
OS4Coding too
Thank you, by advance, for your help
Guillaume
void make_window()
{
win = NewObject(NULL, "window.class",
WINDOW_Position, WPOS_CENTERSCREEN,
WINDOW_Layout, VLayoutObject,
LAYOUT_AddChild, OBJ(OBJ_BUT_GRP) = HGroupObject,
LAYOUT_AddChild, LayoutObject,
LAYOUT_VertAlignment, LALIGN_CENTER,
LAYOUT_HorizAlignment, LALIGN_CENTER,
LAYOUT_AddChild, OBJ(OBJ_IBUT_1) = ButtonObject,
GA_ID, OBJ_IBUT_1,
GA_RelVerify, TRUE,
BUTTON_BevelStyle, BVS_NONE,
BUTTON_Transparent, TRUE,
BUTTON_RenderImage, OBJ(OBJ_SEL_1) = BitMapObject,
BITMAP_SourceFile, "images/pdf",
BITMAP_DisabledSourceFile, "images/pdf_g",
BITMAP_Screen, screen,
BITMAP_Masking, TRUE,
BitMapEnd,
BUTTON_SelectImage, OBJ(OBJ_UNSEL_1) = BitMapObject,
BITMAP_SourceFile, "images/pdf_s",
BITMAP_Screen, screen,
BITMAP_Masking, TRUE,
BitMapEnd,
ButtonEnd,
LAYOUT_AddChild, OBJ(OBJ_IBUT_2) = ButtonObject,
GA_ID, OBJ_IBUT_2,
GA_RelVerify, TRUE,
BUTTON_BevelStyle, BVS_NONE,
BUTTON_Transparent, TRUE,
BUTTON_RenderImage, OBJ(OBJ_SEL_2) = BitMapObject,
BITMAP_SourceFile, "images/picture",
BITMAP_DisabledSourceFile, "images/picture_g",
BITMAP_Screen, screen,
BITMAP_Masking, TRUE,
BitMapEnd,
BUTTON_SelectImage, OBJ(OBJ_UNSEL_2) = BitMapObject,
BITMAP_SourceFile, "images/picture_s",
BITMAP_Screen, screen,
BITMAP_Masking, TRUE,
BitMapEnd,
ButtonEnd,
LabelEnd,
LayoutEnd,
EndHGroup,
CHILD_WeightedHeight, 0,
End, // VLayout
WindowEnd;
int x = 0 ;
for(x = 0; x < 3; x++)
{
Objects[x] = NewObject(NULL, "button.gadget",
GA_ID,x,
GA_RelVerify, TRUE,
GA_Text,"xxx",
TAG_END);
if (Objects[x] == NULL)
{
DisposeObject(OBJ(OBJ_BUT_GRP));
Objects[OBJ_BUT_GRP] = NULL;
return ;
}
SetAttrs(OBJ(OBJ_BUT_GRP),
LAYOUT_AddChild, Objects[x],
TAG_END);
printf("x %d \n",x);
}
}
Edited by zzd10h on 2015/5/10 0:38:28
Edited by zzd10h on 2015/5/10 19:49:52