[Oberon] Dynamically add content to a panel in BB

Dan Parnete dan.parnete at fastwebnet.it
Mon Mar 7 12:47:10 CET 2005


Hello,

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



More information about the Oberon mailing list