List with dynamic faces

Started by OneArb on 15-Mar-2017/18:26:33-7:00
Can list handle dynamic faces? R ebol[ purpose: 'dynamic face list' ] dynamic-face: [] x: copy [] loop 10 [append x reduce [ random 'abcd']] view center-face layout g: [ across li: list 330x400 [ across :dynamic-face rec-no: text 20 text 330 blue ] supply [ face/text: either count > length? x [''][pick x count] rec-no/text: count either (modulo rec-no/text 2) = 0 [ dynamic-face: ['button]] [ dynamic-face: []] ] ]
You can't do dynamic faces in that way. Remember that in a list, there is effectively one pane with one group of sub-faces that are re-shown as many times as they'll fit in the list face. Your best bet here is to hide the face when it represents data where hiding is appropriate. Also remember that supply is iterated over every row (count) and every face within the row (index). li: list 330x400 [ across button "Do Something" [probe face/data] text 20 text 330 blue ] supply [ ; probe as-pair count index ; shows the operative 'position' switch index [ 1 [ face/show?: zero? modulo count 2 face/data: pick x count ] 2 [face/text: form count] 3 [face/text: pick x count] ] ]

Reply