app :: Control :: defaultinit
# A control implementing the UI
class Control
super AppComponent
# Direct parent `Control` in the control tree
#
# The parents (direct and indirect) receive all events from `self`,
# like the `observers`.
#
# If `null` then `self` is at the root of the tree, or not yet attached.
var parent: nullable CompositeControl = null is private writable(set_parent)
# Direct parent `Control` in the control tree
#
# The parents (direct and indirect) receive all events from `self`,
# like the `observers`.
#
# Setting `parent` calls `remove` on the old parent and `add` on the new one.
fun parent=(parent: nullable CompositeControl)
is autoinit do
var old_parent = self.parent
if old_parent != null and old_parent != parent then
old_parent.remove self
end
if parent != null then parent.add self
set_parent parent
end
# Also notify the parents (both direct and indirect)
redef fun notify_observers(event)
do
super
var p = parent
while p != null do
p.on_event event
p = p.parent
end
end
end
lib/app/ui.nit:127,1--168,3