mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
InputDialog: add :addWidget(), use it for checkboxes (#8168)
Also: Text editor now closes its keyboard when calling Find and Go to line (which open their own keyboards) to avoid conflicts between multiple keyboards.
This commit is contained in:
@@ -2,14 +2,11 @@ local BD = require("ui/bidi")
|
||||
local ButtonDialog = require("ui/widget/buttondialog")
|
||||
local CheckButton = require("ui/widget/checkbutton")
|
||||
local Device = require("device")
|
||||
local HorizontalGroup = require("ui/widget/horizontalgroup")
|
||||
local HorizontalSpan = require("ui/widget/horizontalspan")
|
||||
local InfoMessage = require("ui/widget/infomessage")
|
||||
local InputContainer = require("ui/widget/container/inputcontainer")
|
||||
local InputDialog = require("ui/widget/inputdialog")
|
||||
local Notification = require("ui/widget/notification")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local VerticalGroup = require("ui/widget/verticalgroup")
|
||||
local logger = require("logger")
|
||||
local _ = require("gettext")
|
||||
local T = require("ffi/util").template
|
||||
@@ -135,7 +132,6 @@ function ReaderSearch:onShowFulltextSearchInput()
|
||||
},
|
||||
}
|
||||
|
||||
-- checkboxes
|
||||
self.check_button_case = CheckButton:new{
|
||||
text = _("Case sensitive"),
|
||||
checked = not self.case_insensitive,
|
||||
@@ -145,6 +141,7 @@ function ReaderSearch:onShowFulltextSearchInput()
|
||||
self.check_button_case:toggleCheck()
|
||||
end,
|
||||
}
|
||||
self.input_dialog:addWidget(self.check_button_case)
|
||||
self.check_button_regex = CheckButton:new{
|
||||
text = _("Regular expression (hold for help)"),
|
||||
checked = self.use_regex,
|
||||
@@ -157,20 +154,7 @@ function ReaderSearch:onShowFulltextSearchInput()
|
||||
UIManager:show(InfoMessage:new{ text = help_text })
|
||||
end,
|
||||
}
|
||||
|
||||
local checkbox_shift = math.floor((self.input_dialog.width - self.input_dialog._input_widget.width) / 2 + 0.5)
|
||||
local check_buttons = HorizontalGroup:new{
|
||||
HorizontalSpan:new{width = checkbox_shift},
|
||||
VerticalGroup:new{
|
||||
align = "left",
|
||||
self.check_button_case,
|
||||
not self.ui.document.info.has_pages and self.check_button_regex or nil,
|
||||
},
|
||||
}
|
||||
|
||||
-- insert check buttons before the regular buttons
|
||||
local nb_elements = #self.input_dialog.dialog_frame[1]
|
||||
table.insert(self.input_dialog.dialog_frame[1], nb_elements-1, check_buttons)
|
||||
self.input_dialog:addWidget(self.check_button_regex)
|
||||
|
||||
UIManager:show(self.input_dialog)
|
||||
self.input_dialog:onShowKeyboard()
|
||||
|
||||
Reference in New Issue
Block a user