tags:

views:

97

answers:

1

I've been trying to remove a slot from a child button click, but I can't seem to get it to work. E.G.

flow do
  button("X") {parent.remove}
end

Any suggestions?

+1  A: 

Shoes' blocks are sometimes tricky. The key here is to ask yourself, what is the parent method being called upon? self, of course. And self references the app (or window, or dialog), not the button.

There are two similar ways to get around this. First, you can create a reference to the button to use in the block:

flow do
  a = button("X") {a.parent.remove}
end

Or, you could just reference the slot itself:

b = flow do
  button("X") {b.remove}
end
Pesto
Thanks I was trying something more complicated than I needed. Now I can't figure out a method to call to force an update to the window.
Never mind, if I hide it then remove it the slot is updated properly.