From 9c03c950ad47efcb8b0b08ac5db863f361c56123 Mon Sep 17 00:00:00 2001 From: Insality Date: Thu, 21 Nov 2024 00:51:35 +0200 Subject: [PATCH] Remove on_message_input functional --- druid/base/button.lua | 25 ------------------------- druid/base/text.lua | 11 ----------- druid/component.lua | 3 --- druid/const.lua | 1 - druid/system/druid_instance.lua | 13 +------------ 5 files changed, 1 insertion(+), 52 deletions(-) diff --git a/druid/base/button.lua b/druid/base/button.lua index e21e7d9..ce93c85 100755 --- a/druid/base/button.lua +++ b/druid/base/button.lua @@ -444,31 +444,6 @@ function M:on_input_interrupt() end -function M:on_message_input(node_id, message) - if node_id ~= self.node_id or self.disabled or not gui.is_enabled(self.node) then - return false - end - - if message.action == const.MESSAGE_INPUT.BUTTON_CLICK then - on_button_click(self) - end - - if message.action == const.MESSAGE_INPUT.BUTTON_LONG_CLICK then - on_button_long_click(self) - end - - if message.action == const.MESSAGE_INPUT.BUTTON_DOUBLE_CLICK then - on_button_double_click(self) - end - - if message.action == const.MESSAGE_INPUT.BUTTON_REPEATED_CLICK then - on_button_repeated_click(self) - self.is_repeated_started = false - self.last_pressed_time = socket.gettime() - end -end - - --- Set button enabled state. -- The style.on_set_enabled will be triggered. -- Disabled button is not clickable. diff --git a/druid/base/text.lua b/druid/base/text.lua index 7d394a8..ee05801 100755 --- a/druid/base/text.lua +++ b/druid/base/text.lua @@ -357,17 +357,6 @@ function M:on_layout_change() end -function M:on_message_input(node_id, message) - if node_id ~= self.node_id then - return false - end - - if message.action == const.MESSAGE_INPUT.TEXT_SET then - M.set_text(self, message.value) - end -end - - --- Calculate text width with font with respect to trailing space ---@param text string|nil ---@return number Width diff --git a/druid/component.lua b/druid/component.lua index 37e12ce..31890d4 100644 --- a/druid/component.lua +++ b/druid/component.lua @@ -50,7 +50,6 @@ M.ON_LATE_INIT = const.ON_LATE_INIT M.ON_FOCUS_LOST = const.ON_FOCUS_LOST M.ON_FOCUS_GAINED = const.ON_FOCUS_GAINED M.ON_LAYOUT_CHANGE = const.ON_LAYOUT_CHANGE -M.ON_MESSAGE_INPUT = const.ON_MESSAGE_INPUT M.ON_WINDOW_RESIZED = const.ON_WINDOW_RESIZED M.ON_LANGUAGE_CHANGE = const.ON_LANGUAGE_CHANGE @@ -62,7 +61,6 @@ M.ALL_INTERESTS = { M.ON_FOCUS_LOST, M.ON_FOCUS_GAINED, M.ON_LAYOUT_CHANGE, - M.ON_MESSAGE_INPUT, M.ON_WINDOW_RESIZED, M.ON_LANGUAGE_CHANGE, } @@ -73,7 +71,6 @@ M.SPECIFIC_UI_MESSAGES = { [hash(M.ON_FOCUS_LOST)] = M.ON_FOCUS_LOST, [hash(M.ON_FOCUS_GAINED)] = M.ON_FOCUS_GAINED, [hash(M.ON_WINDOW_RESIZED)] = M.ON_WINDOW_RESIZED, - [hash(M.ON_MESSAGE_INPUT)] = M.ON_MESSAGE_INPUT, [hash(M.ON_LANGUAGE_CHANGE)] = M.ON_LANGUAGE_CHANGE, } diff --git a/druid/const.lua b/druid/const.lua index 8bfd3d1..25d6b88 100755 --- a/druid/const.lua +++ b/druid/const.lua @@ -26,7 +26,6 @@ M.ON_LATE_INIT = "on_late_init" M.ON_FOCUS_LOST = "on_focus_lost" M.ON_FOCUS_GAINED = "on_focus_gained" M.ON_LAYOUT_CHANGE = "on_layout_change" -M.ON_MESSAGE_INPUT = "on_message_input" M.ON_WINDOW_RESIZED = "on_window_resized" M.ON_LANGUAGE_CHANGE = "on_language_change" diff --git a/druid/system/druid_instance.lua b/druid/system/druid_instance.lua index 2260516..0e2d9b7 100755 --- a/druid/system/druid_instance.lua +++ b/druid/system/druid_instance.lua @@ -386,18 +386,7 @@ end function M:on_message(message_id, message, sender) local specific_ui_message = base_component.SPECIFIC_UI_MESSAGES[message_id] - if specific_ui_message == base_component.ON_MESSAGE_INPUT then - -- ON_MESSAGE_INPUT is special message, need to perform additional logic - local components = self.components_interest[base_component.ON_MESSAGE_INPUT] - if components then - for i = 1, #components do - local component = components[i] - if can_use_input_component(self, component) then - component[specific_ui_message](component, hash(message.node_id), message) - end - end - end - elseif specific_ui_message then + if specific_ui_message then -- Resend special message to all components with the related interest local components = self.components_interest[specific_ui_message] if components then