Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: How to change content of text-list?

From: gscottjones:mchsi at: 1-Feb-2003 7:34

Hi, Yogi, From: "Marc Michael"
> I have written this test-code: > > REBOL[ > Title: "listentest3" > ] > view layout[ > textliste: text-list data ["Apfel" "Birne" "Pflaume"] > button "Liste 1" [ > textliste/data: ["eins" "zwei" "drei"] > show textliste > ] > button "Liste 2" [ > append textliste/data "vier" > show textliste > ] > ] > > If I press directly after starting the programm on button Liste 2, the > string "vier" is added to the text-list in the GUI. But if I press on > the button Liste 1 nothing happens. If I press after that on button > Liste 2, also nothing happens. This looks very strange to me. Is it > possible to assign a new block as content to a text-list?
You may find a few different points of view on this issue (I was surprised someone hasn't already written). Before I go further let me warn you that this functionality is **expected to change** in the future, so anything you do now may break in a year. That warning aside, your example demonstrates what many people have tried because it intuitively "seems" right. However what works is as follows. You need to use the /lines instead of the /data path, and when assigning a fresh data list you need to use COPY. There is one other inconsistency that I cannot seem to remember right now. Here is the code. REBOL[ Title: "listentest3" ] view layout[ textliste: text-list data ["Apfel" "Birne" "Pflaume"] button "Liste 1" [ textliste/lines: copy ["eins" "zwei" "drei"] show textliste ] button "Liste 2" [ append textliste/lines "vier" show textliste ] ] The next problem that you will run into is that the list slider does not automatically update after the list grows too long. Click the button a time or two in the following segement: view layout[ textliste: text-list data ["Apfel" "Birne" "Pflaume" "eins" "zwei" "drei" "vier"] button "Liste 1" [ append textliste/lines ["Apfel1" "Birne1" "Pflaume1" "eins1" "zwei1" "drei1" "vier1"] show textliste ] ] The slider length stays the same. :( The workaround is a function that has evolved over time. (The original may have been Sterling???). Currently, it very closely mimics what other code in /View uses. fix-slider: func [faces [object! block!]] [ foreach list to-block faces [ list/sld/redrag list/lc / max 1 length? head list/lines ] ] view layout[ textliste: text-list data ["Apfel" "Birne" "Pflaume" "eins" "zwei" "drei" "vier"] button "Liste 1" [ append textliste/lines ["Apfel1" "Birne1" "Pflaume1" "eins1" "zwei1" "drei1" "vier1"] fix-slider textliste show textliste ] ] This functionality also is expected to change with the next /View VID release. Hope this helps. --Scott Jones