[Oberon] Dynamically add content to a panel in BB

Thomas Frey frey at inf.ethz.ch
Mon Mar 7 13:01:44 CET 2005


When elements are dynamically added, they should be reseted after the 
insertion. This is done automatically with the SetContent procedure.

after
panel.AddContent(field)
insert
field.Reset(SELF, NIL);

this should solve the problem.
The reset is propagated to sub components, so only the top-most element 
of a newly added component structure needs to be reset.

In case of the insertion of automatically aligned components, a 
panel.AlignSubComponents would cause a redistribution of the available 
space. This is not needed in your example with explicite alignment.

--Thomas


> I'm trying to understand how to dynamically add content to a panel. In 
> the fallowing code, the AddHandler procedure displays the new added 
> editor, but:
>    - if I use only the panel.Invalidate to redraw the panel, the new 
> editor space is empty.
>    - if I use win.SetContent the editor looks normal and functional, bat 
> there is an
> Trap 8 ASSERT failed in thread MsgSequencer
> Module: WMComponents at PC = 13091
> 
> Could anybody help me to understand how to manage that?
> 
> 
> VAR
>    panel: WMStandardComponents.Panel;
>    win: WMComponents.FormWindow;
>    field: WMEditors.Editor;
>    but: WMStandardComponents.Button;
> 
> PROCEDURE Run*(ptr: PTR): PTR;
> BEGIN
>    NEW(panel);  panel.bounds.SetExtents(200, 200);
>    panel.fillColor.Set(0CCCCCCFFH);  panel.takesFocus.Set(TRUE);
>    NEW(but); but.caption.SetAOC("Add");  but.bounds.SetExtents(50,20);
>    but.onClick.Add(AddHandler);
>    panel.AddContent(but);
>    NEW(field);  field.tv.showBorder.Set(TRUE);
>    field.tv.borders.Set(WMRectangles.MakeRect(3,3,1,1));
>    field.bounds.SetExtents(100,20);  field.bounds.SetTop(20);
>    field.multiLine.Set(FALSE);  field.fillColor.Set(0FFFFFFFFH);
>    field.SetAsString("Hello");
>    panel.AddContent(field);   
>    NEW(win, panel.bounds.GetWidth(), panel.bounds.GetHeight(), FALSE);
>    win.SetContent(panel);
>    WMWindowManager.DefaultAddWindow(win);
>       RETURN NIL
> END Run;
> 
> PROCEDURE AddHandler(sender, data: ANY);
> BEGIN
>    NEW(field);  field.tv.showBorder.Set(TRUE);
>    field.tv.borders.Set(WMRectangles.MakeRect(3,3,1,1));
>    field.bounds.SetExtents(100,20);  field.bounds.SetTop(40);
>    field.multiLine.Set(FALSE);  field.fillColor.Set(0FFFFFFFFH);
>    field.SetAsString("World");
>    panel.AddContent(field);
>    (*panel.InvalidateRect(WMRectangles.MakeRect(0,40,100,60));*)
>    panel.Invalidate;
>    (*win.SetContent(panel);*)
> END AddHandler;
> 
> Thank you,
> Dan Parnete
> -- 
> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
> https://www.mail.inf.ethz.ch/lists/listinfo/oberon




More information about the Oberon mailing list