Sometimes self is not app !!!
class SubShoes < Shoes
url "/", :index
def index
para "app : #{app.inspect} ** self : #{self}"
# self is app.slot
end
end
Shoes.app title: "SubShoesApp"
Here
- app is not self
- self is app.slot
- self has a parent slot which is the Superclass canvas
self.parent.is_a? Shoes::Canvas #=> true
click, release callbacks inside :index must be called against self.parent NOT app or app.slot or self
keypress is happy with implicit self (redirect to app anyway ?)
There is one more slot nesting with Class-Shoes.app
class SubShoes < Shoes
url "/", :index
url "/elsewhere", :new_page
def index
visit "/elsewhere"
# self is NOT app.slot
#... some more code that runs after visit
end
def new_page
para "app : #{app.inspect} ** self : #{self}"
# self is app.slot
end
end
Shoes.app title: "SubShoesApp"
Here (expert_tankspank.rb is doing it that way)
- app is not self
- self is NOT app.slot in :index !
- self is app.slot in :new_page !
- self has a parent slot
- self.parent is not app.slot in :index and in :new_page
- app.slot is self.parent.contents[0] in :index AND in :new_page !!
self in :index is a hidden/not accessible Shoes::Canvas
Drawing happens on :new_page not :index
There is 2 different Canvas
in :new_page (like new Shoes::Canvas)
- Root slot >> app.slot(self) >> elements
in :index (not accessible)
- Root slot >> app.slot >> elements(not accessible)
- What is self in :index ? i know it's a Shoes::Canvas, not app.slot, so it's probably the "hidden" one
I think the concept is that self is set to the calling block class/object so self inside a edit_line {} is the the edit_line object
app is set to the enclosing Window aka Shoes.app or Shoes:::Window or url that contains the gui object asking for 'app.something'.
APPS is an array of known Shoes.apps each or them with different objects in the app variable. Contrived example:
In Window #1 (say it's Shoes.app) {} you've created a new Window (Shoes). APPS.size = 2. APPS[0].app and APPS[1].app point to two different objects. Self is set to which ever block is executing - maybe its inside a button block in Window 2 or in an edit_line in Window-1. In Shoes, self is transient and runtime context dependent.
I'm not sure that helps. It really is hard to describe.