irc: fix live updates and preserve default buttons on reopen
- Set in so append/refresh repaint. - Build button rows explicitly (Send + TextViewer defaults) and disable automatic default insertion to ensure defaults remain after reinit. Also clarifies behavior when reopening a keep_running view. Signed-off-by: Slendi <slendi@socopon.com>
This commit is contained in:
68
main.lua
68
main.lua
@@ -48,17 +48,67 @@ local IrcChatView = TextViewer:extend{
|
||||
}
|
||||
|
||||
function IrcChatView:init(reinit)
|
||||
-- Buttons: Send, Close
|
||||
self.buttons_table = {
|
||||
-- Mark UI as open so append/refresh paths repaint immediately
|
||||
self._ui_open = true
|
||||
-- Build buttons: first our Send row, then TextViewer's default row
|
||||
-- Disable TextViewer's automatic default buttons to avoid duplication
|
||||
self.add_default_buttons = false
|
||||
local send_row = {
|
||||
{
|
||||
{
|
||||
text = _("Send"),
|
||||
callback = function()
|
||||
self:promptSendMessage()
|
||||
end,
|
||||
},
|
||||
}
|
||||
text = _("Send"),
|
||||
callback = function()
|
||||
self:promptSendMessage()
|
||||
end,
|
||||
},
|
||||
}
|
||||
local default_row = {
|
||||
{
|
||||
text = _("Find"),
|
||||
id = "find",
|
||||
callback = function()
|
||||
if self._find_next then
|
||||
self:findCallback()
|
||||
else
|
||||
self:findDialog()
|
||||
end
|
||||
end,
|
||||
hold_callback = function()
|
||||
if self._find_next then
|
||||
self:findDialog()
|
||||
else
|
||||
if self.default_hold_callback then
|
||||
self.default_hold_callback()
|
||||
end
|
||||
end
|
||||
end,
|
||||
},
|
||||
{
|
||||
text = "⇱",
|
||||
id = "top",
|
||||
callback = function()
|
||||
if self.scroll_text_w then self.scroll_text_w:scrollToTop() end
|
||||
end,
|
||||
hold_callback = self.default_hold_callback,
|
||||
allow_hold_when_disabled = true,
|
||||
},
|
||||
{
|
||||
text = "⇲",
|
||||
id = "bottom",
|
||||
callback = function()
|
||||
if self.scroll_text_w then self.scroll_text_w:scrollToBottom() end
|
||||
end,
|
||||
hold_callback = self.default_hold_callback,
|
||||
allow_hold_when_disabled = true,
|
||||
},
|
||||
{
|
||||
text = _("Close"),
|
||||
callback = function()
|
||||
self:onClose()
|
||||
end,
|
||||
hold_callback = self.default_hold_callback,
|
||||
},
|
||||
}
|
||||
self.buttons_table = { send_row, default_row }
|
||||
-- Buffers & title
|
||||
if not reinit then
|
||||
self._buffers = {}
|
||||
|
||||
Reference in New Issue
Block a user