问题
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