Path: news.cs.au.dk!not-for-mail From: Manmathan Muthukumarapillai Newsgroups: comp.lang.beta Subject: Re: Making new pushbuttons at runtime Date: 27 Jul 1999 11:15:24 -0000 Organization: Mjolner Informatics ApS, Denmark Lines: 112 Approved: mailtonews@cs.au.dk Distribution: world Message-ID: <19990727111524.17679.qmail@noatun.mjolner.dk> Reply-To: Manmathan Muthukumarapillai NNTP-Posting-Host: daimi.cs.au.dk X-Trace: xinwen.cs.au.dk 933074141 6276166 255.255.255.255 (27 Jul 1999 11:15:41 GMT) X-Complaints-To: news@cs.au.dk NNTP-Posting-Date: 27 Jul 1999 11:15:41 GMT Xref: news.cs.au.dk comp.lang.beta:12042 Hi Bo! I hope this litle program demostrates a possible solution for you: ORIGIN '~beta/guienv/controls'; -- windowLib: Attributes -- createbutton: (# pbut: ^pushbutton; father: ^canvas; mylabel: ^text; xpos,ypos: @integer; enter (father[],mylabel[],xpos,ypos) (* the pushbutton will be placed inside the "father" canvas *) (* If it should be placed inside a window, then window.contents returns a canvas *) do &pushbutton[]->pbut[]; father[]->pbut.open; mylabel[]->pbut.label; (xpos,ypos)->pbut.position; exit pbut[] #); -- program: descriptor -- guienv (# mywin2: @window (# open::(# do 'mywin2'->title; #); #); mainwin: @window (# mybut:[2]^pushbutton; open:: (# do 'mainwin'->title; (mywin2.contents,'Hello in mywin2',30,10) -> createbutton->mybut[1][]; (contents,'Hello in mainwin',0,80) -> createbutton->mybut[2][]; #); #); do mywin2.open; mainwin.open; #) Sincerely, Manmathan Muthukumarapillai / Mjolner Informatics (mannan@mjolner.dk) +++++++++++++++++++ BETA information Sources ++++++++++++++++++++++++ + Mjolner Informatics | Phone: +45 8620 2000 + + Science Park Aarhus | Direct: +45 8620 2011 local 2672 + + Gustav Wieds Vej 10 | Fax: +45 8620 1222 + + DK-8000, Aarhus C, Denmark | E-mail: info@mjolner.com + + WWW : http://www.mjolner.com -and- http://www.daimi.aau.dk/~beta + + FAQ : http://www.daimi.aau.dk/~beta/FAQ News: comp.lang.beta + + News: comp.lang.beta + +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Tue, Jul 27, 1999 at 12:07:28PM +0200 Bo Normann wrote: > Hello, > > I've run into another problem and I hope that someone is able to help me > : > > The problem is that I need to make some pushbuttons at runtime and the > number of buttons may vary, and I can't seem to make it work without > declaring a constant number of pushbuttons, but that is not an okay > solution in this case, so if anyone know how to dynamically invoke new > pushbuttons I'd be grateful. > > I've tried something like this : > inx_list is an integer > Buttons is arraycontainer of generel pushbuttons > Button is a generel button : > Generel_button: pushbutton > (# > Label_button : ^Text; > x_pos,y_pos: @integer; > open::< > (# > do > Label_button[]->label; > borderStyles.shadowOut->border.style; > (60,20)->size; > (x_pos,y_pos)->position; > #); > > eventhandler ::< > (# OnMouseUp ::< (# do INNER #) #); > > enter(Label_button[],x_pos,y_pos) > #); > > And what I've tried is the following : > > (inx_list)-> Buttons.get->Button[]; > (Text[],(inx_r-1)*65+15,(inx_s-1)*25+35)-> > Button; > (Button[],inx_liste)-> Buttons.put; > > But I only get one pushbutton it seems and position is (0,0) > > Any help is appriciated > > Please mail me at normann@stofanet.dk > > Kind regards > Bo >