Printing out text of all GUI elements in Red language

懵懂的女人 提交于 2019-12-24 00:33:17

问题


I am trying to print out text from all GUI elements in following code:

  sentlist: ["A" "B" "C"]

  main: function [slist] [
      view collect [
          repeat i length? slist [
              keep compose [
                  text (slist/:i)
                  field "" 
                  return ]]
          keep [button "Printall" [
              repeat i (2 * length? slist)[
                  print face/parent/pane/(i)/text  ]]]]]

 (main sentlist) 

It runs all right without any error and text elements' text are properly printed out, but for fields, only last field's entry is printed out for each field. Where is the problem and how can it be corrected? Thanks for your help.


回答1:


In your spec field "" reuses the same string to each of the fields. Changing one field changes the text for each (likely for efficiency reasons, this is not reflected in the GUI). You could change the line to field (copy "") to provide a unique string.



来源:https://stackoverflow.com/questions/46285290/printing-out-text-of-all-gui-elements-in-red-language

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!