Closed hiiamboris closed 4 years ago
This seems to work for me:
view [
text "A"
text "B"
button "C1" [foreach-face face/parent [print face/text break]]
button "C2" [foreach-face face/parent [print face/text break/return "break/return"]]
button "C3" [foreach-face face/parent [print face/text return "return"]]
]
Try this:
v: view/no-wait [
text "A"
panel [text "B"] "X"
panel [text "C"] "Y"
]
foreach-face v [
print face/text
if face/text = "B" [print "STOPPING..." break]
]
v: view/no-wait [
text "A"
text "B"
button "C1" [foreach-face face/parent [print face/text break]]
button "C2" [foreach-face face/parent [print face/text break/return "break/return"]]
button "C3" [foreach-face face/parent [print face/text return "return"]]
]
foreach-face v [
print face/text
if face/text = "B" [print "STOPPING..." break]
]
Results in
A
B
STOPPING...
== [make object! [
type: 'button
offset: 190x9
size: 62x27
text: "C1"
image: none
color: none
m...
But
v: view/no-wait [
text "A"
panel [text "B"] "X"
button "C1" [foreach-face face/parent [print face/text break]]
button "C2" [foreach-face face/parent [print face/text break/return "break/return"]]
button "C3" [foreach-face face/parent [print face/text return "return"]]
]
foreach-face v [
print face/text
if face/text = "B" [print "STOPPING..." break]
]
Results in
A
X
B
STOPPING...
C1
C2
C3
== []
Panel
handling (/sub
) appears to be the culprit.
Should I repost this to https://github.com/red/red/issues/ ?
I think so. It's a good subject for an article, as well as figuring out how best to design things (including HOF-esque stuff like this), without making it an advanced topic that only a non-local-flow-control continuation-passing mother could love.
There's a solution
it does not react to
break/return
orreturn
and continues to process the whole tree