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

[ALLY] Making dynamic button layouts in VIEW

From: bo:rebol at: 29-Jan-2001 16:47

I get asked this question from time to time and there is some insight involved into how VIEW works, so I thought I would post an example to this list for the enlightenment of all: ;This is a template for a blank button button-layout: layout [button "text" []] ;This is your main VIEW view layout [ text "Enter names for some buttons divided by spaces" f: field 200 button "Show me!" [ ;; first, start off with an empty face to hold the buttons button-face: layout [] ;; keep an offset variable so we know where each button goes ofst: 0x0 ;; Break input from field above into a series of strings ;; and perform some actions on each one foreach item parse f/text none [ ;; The /pane is where sub-faces are stored. ;; This adds the modified blank button templates into the ;; blank button face we created above. append button-face/pane make button-layout/pane/1 [ offset: ofst ;; Buttons expect their label to be in a field called ;; 'texts' which is a block of strings. texts: reduce [item] ;; The action field determines what will be done when ;; the button is clicked. The COMPOSE statement ;; reduces only the items in parentheses (). action: func [f e] compose [request/ok (item)] ] ;; Increment the offset for the next button ofst: ofst + (button-layout/pane/1/size * 0x1) ] ;; Set the size for the button-face based on the last offset. button-face/size: ofst + button-layout/pane/1/size ;; View it! view/new button-face ] ] Have fun! -- Bohdan "Bo" Lechnowsky REBOL Adventure Guide REBOL Technologies 707-467-8000 ( The Official Source for REBOL Books (