mirror of
https://github.com/Insality/druid
synced 2025-09-27 18:12:21 +02:00
Add list of druid instances, add global events: on_window_callback, on_layout_change and on_language_change
This commit is contained in:
@@ -111,6 +111,8 @@ end
|
||||
function Druid.initialize(self, context, style)
|
||||
self._context = context
|
||||
self._style = style or settings.default_style
|
||||
self._deleted = false
|
||||
self.url = msg.url()
|
||||
self.components = {}
|
||||
end
|
||||
|
||||
@@ -141,6 +143,8 @@ function Druid.final(self)
|
||||
components[i]:on_remove()
|
||||
end
|
||||
end
|
||||
|
||||
self._deleted = true
|
||||
end
|
||||
|
||||
|
||||
@@ -231,6 +235,45 @@ function Druid.on_message(self, message_id, message, sender)
|
||||
end
|
||||
|
||||
|
||||
function Druid.on_focus_lost(self)
|
||||
local components = self.components[const.ON_FOCUS_LOST]
|
||||
if components then
|
||||
for i = 1, #components do
|
||||
components[i]:on_focus_lost()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Druid.on_focus_gained(self)
|
||||
local components = self.components[const.ON_FOCUS_GAINED]
|
||||
if components then
|
||||
for i = 1, #components do
|
||||
components[i]:on_focus_gained()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function Druid.on_layout_change(self)
|
||||
local components = self.components[const.ON_LAYOUT_CHANGE]
|
||||
if components then
|
||||
for i = 1, #components do
|
||||
components[i]:on_layout_change()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function Druid.on_language_change(self)
|
||||
local components = self.components[const.ON_LANGUAGE_CHANGE]
|
||||
if components then
|
||||
for i = 1, #components do
|
||||
components[i]:on_language_change()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--- Create button basic component
|
||||
-- @function druid:new_button
|
||||
-- @tparam args ... button init args
|
||||
|
Reference in New Issue
Block a user