diff --git a/frontend/apps/filemanager/filemanagerfilesearcher.lua b/frontend/apps/filemanager/filemanagerfilesearcher.lua index 66875b271..e6183aa6f 100644 --- a/frontend/apps/filemanager/filemanagerfilesearcher.lua +++ b/frontend/apps/filemanager/filemanagerfilesearcher.lua @@ -158,9 +158,7 @@ function FileSearcher:onShowFileSearch(search_string) text = _("Case sensitive"), checked = self.case_sensitive, parent = self.search_dialog, - max_width = self.search_dialog._input_widget.width, callback = function() - self.check_button_case:toggleCheck() self.case_sensitive = self.check_button_case.checked end, } diff --git a/frontend/apps/reader/modules/readerbookmark.lua b/frontend/apps/reader/modules/readerbookmark.lua index 6a574cb7a..cf47b56e7 100644 --- a/frontend/apps/reader/modules/readerbookmark.lua +++ b/frontend/apps/reader/modules/readerbookmark.lua @@ -916,10 +916,6 @@ function ReaderBookmark:onSearchBookmark(bm_menu) text = " " .. _("Case sensitive"), checked = false, parent = input_dialog, - max_width = input_dialog._input_widget.width, - callback = function() - check_button_case:toggleCheck() - end, } input_dialog:addWidget(check_button_case) separator = CenterContainer:new{ @@ -940,30 +936,18 @@ function ReaderBookmark:onSearchBookmark(bm_menu) text = " " .. DISPLAY_PREFIX["highlight"] .. _("highlights"), checked = true, parent = input_dialog, - max_width = input_dialog._input_widget.width, - callback = function() - check_button_highlight:toggleCheck() - end, } input_dialog:addWidget(check_button_highlight) check_button_note = CheckButton:new{ text = " " .. DISPLAY_PREFIX["note"] .. _("notes"), checked = true, parent = input_dialog, - max_width = input_dialog._input_widget.width, - callback = function() - check_button_note:toggleCheck() - end, } input_dialog:addWidget(check_button_note) check_button_bookmark = CheckButton:new{ text = " " .. DISPLAY_PREFIX["bookmark"] .. _("page bookmarks"), checked = true, parent = input_dialog, - max_width = input_dialog._input_widget.width, - callback = function() - check_button_bookmark:toggleCheck() - end, } input_dialog:addWidget(check_button_bookmark) diff --git a/frontend/apps/reader/modules/readersearch.lua b/frontend/apps/reader/modules/readersearch.lua index 8580b6f68..32e57584e 100644 --- a/frontend/apps/reader/modules/readersearch.lua +++ b/frontend/apps/reader/modules/readersearch.lua @@ -139,20 +139,12 @@ function ReaderSearch:onShowFulltextSearchInput() text = _("Case sensitive"), checked = not self.case_insensitive, parent = self.input_dialog, - max_width = self.input_dialog._input_widget.width, - callback = function() - self.check_button_case:toggleCheck() - end, } self.input_dialog:addWidget(self.check_button_case) self.check_button_regex = CheckButton:new{ text = _("Regular expression (long-press for help)"), checked = self.use_regex, parent = self.input_dialog, - max_width = self.input_dialog._input_widget.width, - callback = function() - self.check_button_regex:toggleCheck() - end, hold_callback = function() UIManager:show(InfoMessage:new{ text = help_text, diff --git a/frontend/ui/elements/menu_keyboard_layout.lua b/frontend/ui/elements/menu_keyboard_layout.lua index 3ec286b65..0270cb9af 100644 --- a/frontend/ui/elements/menu_keyboard_layout.lua +++ b/frontend/ui/elements/menu_keyboard_layout.lua @@ -118,30 +118,18 @@ local sub_item_table = { text = _("in bold"), checked = G_reader_settings:isTrue("keyboard_key_bold"), parent = input_dialog, - max_width = input_dialog._input_widget.width, - callback = function() - check_button_bold:toggleCheck() - end, } input_dialog:addWidget(check_button_bold) check_button_border = CheckButton:new{ text = _("with border"), checked = G_reader_settings:nilOrTrue("keyboard_key_border"), parent = input_dialog, - max_width = input_dialog._input_widget.width, - callback = function() - check_button_border:toggleCheck() - end, } input_dialog:addWidget(check_button_border) check_button_compact = CheckButton:new{ text = _("compact"), checked = G_reader_settings:isTrue("keyboard_key_compact"), parent = input_dialog, - max_width = input_dialog._input_widget.width, - callback = function() - check_button_compact:toggleCheck() - end, } input_dialog:addWidget(check_button_compact) diff --git a/frontend/ui/widget/checkbutton.lua b/frontend/ui/widget/checkbutton.lua index 2c6e87a5d..afaaef947 100644 --- a/frontend/ui/widget/checkbutton.lua +++ b/frontend/ui/widget/checkbutton.lua @@ -35,7 +35,9 @@ local CheckButton = InputContainer:new{ face = Font:getFace("smallinfofont"), background = Blitbuffer.COLOR_WHITE, text = nil, - max_width = nil, -- must be set by the caller + parent = nil, -- parent widget, must be set by the caller + width = nil, -- default value: parent widget's input widget width + -- If the parent widget has no input widget, the width must be set by the caller. } function CheckButton:init() @@ -54,7 +56,7 @@ function CheckButton:initCheckButton(checked) self._textwidget = TextBoxWidget:new{ text = self.text, face = self.face, - width = self.max_width - self._checkmark.dimen.w, + width = (self.width or self.parent._input_widget.width) - self._checkmark.dimen.w, fgcolor = self.enabled and Blitbuffer.COLOR_BLACK or Blitbuffer.COLOR_DARK_GRAY, } local textbox_shift = math.max(0, self._checkmark.baseline - self._textwidget:getBaseline()) @@ -109,9 +111,17 @@ function CheckButton:initCheckButton(checked) end function CheckButton:onTapCheckButton() - if self.enabled and self.callback then + if not self.enabled then return true end + if self.tap_input then + self:onInput(self.tap_input) + elseif type(self.tap_input_func) == "function" then + self:onInput(self.tap_input_func()) + else if G_reader_settings:isFalse("flash_ui") then - self.callback() + self:toggleCheck() + if self.callback then + self.callback() + end else -- c.f., ui/widget/iconbutton for the canonical documentation about the flash_ui code flow @@ -134,14 +144,13 @@ function CheckButton:onTapCheckButton() -- Callback -- - self.callback() + self:toggleCheck() + if self.callback then + self.callback() + end UIManager:forceRePaint() end - elseif self.tap_input then - self:onInput(self.tap_input) - elseif type(self.tap_input_func) == "function" then - self:onInput(self.tap_input_func()) end return true end diff --git a/frontend/ui/widget/inputdialog.lua b/frontend/ui/widget/inputdialog.lua index efe5b4703..b9056031f 100644 --- a/frontend/ui/widget/inputdialog.lua +++ b/frontend/ui/widget/inputdialog.lua @@ -867,9 +867,7 @@ function InputDialog:_addScrollButtons(nav_bar) text = _("Case sensitive"), checked = self.case_sensitive, parent = input_dialog, - max_width = input_dialog._input_widget.width, callback = function() - self.check_button_case:toggleCheck() self.case_sensitive = self.check_button_case.checked end, } diff --git a/frontend/ui/widget/inputtext.lua b/frontend/ui/widget/inputtext.lua index fdda87821..84541ff93 100644 --- a/frontend/ui/widget/inputtext.lua +++ b/frontend/ui/widget/inputtext.lua @@ -393,9 +393,8 @@ function InputText:initTextBox(text, char_added) self._check_button = self._check_button or CheckButton:new{ text = _("Show password"), parent = self, - max_width = self.width, + width = self.width, callback = function() - self._check_button:toggleCheck() self.text_type = self._check_button.checked and "text" or "password" self:setText(self:getText(), true) end, diff --git a/frontend/ui/widget/openwithdialog.lua b/frontend/ui/widget/openwithdialog.lua index e7be0edf3..ee454eee0 100644 --- a/frontend/ui/widget/openwithdialog.lua +++ b/frontend/ui/widget/openwithdialog.lua @@ -63,13 +63,8 @@ function OpenWithDialog:init() self._check_file_button = self._check_file_button or CheckButton:new{ text = _("Always use this engine for this file"), - callback = function() - self._check_file_button:toggleCheck() - end, - - max_width = self.element_width, + width = self.element_width, face = self.face, - parent = self, } self._always_file_toggle = LeftContainer:new{ @@ -83,13 +78,8 @@ function OpenWithDialog:init() self._check_global_button = self._check_global_button or CheckButton:new{ text = _("Always use this engine for file type"), - callback = function() - self._check_global_button:toggleCheck() - end, - - max_width = self.element_width, + width = self.element_width, face = self.face, - parent = self, } self._always_global_toggle = LeftContainer:new{