Fix selection
Perhaps it would be wise to move widget local variables to some sort of global variable for each tab.
This commit is contained in:
parent
f35c939fc3
commit
cf90bb9807
|
@ -117,15 +117,9 @@ function init()
|
||||||
if not consoleBuffer then return false end
|
if not consoleBuffer then return false end
|
||||||
|
|
||||||
local consoleLabel = consoleBuffer:getFocusedChild()
|
local consoleLabel = consoleBuffer:getFocusedChild()
|
||||||
if not consoleLabel.selectionChildFirst or not consoleLabel.selectionChildLast then return false end
|
if not consoleLabel then return false end
|
||||||
|
|
||||||
local text = {}
|
g_window.setClipboardText(getSelection(consoleLabel))
|
||||||
for selectionChild = consoleLabel.selectionChildFirst, consoleLabel.selectionChildLast do
|
|
||||||
local label = consoleLabel:getParent():getChildByIndex(selectionChild)
|
|
||||||
table.insert(text, label:getSelection())
|
|
||||||
end
|
|
||||||
|
|
||||||
g_window.setClipboardText(table.concat(text, '\r\n'))
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -153,6 +147,20 @@ function init()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function getSelection(widget)
|
||||||
|
if not widget.selectionChildFirst or not widget.selectionChildLast then
|
||||||
|
return widget:getSelection()
|
||||||
|
end
|
||||||
|
|
||||||
|
local text = {}
|
||||||
|
for selectionChild = widget.selectionChildFirst, widget.selectionChildLast do
|
||||||
|
local label = widget:getParent():getChildByIndex(selectionChild)
|
||||||
|
table.insert(text, label:getSelection())
|
||||||
|
end
|
||||||
|
|
||||||
|
return table.concat(text, '\r\n')
|
||||||
|
end
|
||||||
|
|
||||||
function toggleChat()
|
function toggleChat()
|
||||||
if consoleToggleChat:isChecked() then
|
if consoleToggleChat:isChecked() then
|
||||||
disableChat()
|
disableChat()
|
||||||
|
@ -592,6 +600,8 @@ function addTabText(text, speaktype, tab, creatureName)
|
||||||
label:clearSelection()
|
label:clearSelection()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self.selectionChildFirst = nil
|
||||||
|
self.selectionChildLast = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -703,7 +713,7 @@ function processMessageMenu(mousePos, mouseButton, creatureName, text, label, ta
|
||||||
menu:addOption(tr('Copy name'), function () g_window.setClipboardText(creatureName) end)
|
menu:addOption(tr('Copy name'), function () g_window.setClipboardText(creatureName) end)
|
||||||
end
|
end
|
||||||
if label:hasSelection() then
|
if label:hasSelection() then
|
||||||
menu:addOption(tr('Copy'), function() g_window.setClipboardText(label:getSelection()) end, '(Ctrl+C)')
|
menu:addOption(tr('Copy'), function() g_window.setClipboardText(getSelection(label)) end, '(Ctrl+C)')
|
||||||
end
|
end
|
||||||
menu:addOption(tr('Copy message'), function() g_window.setClipboardText(text) end)
|
menu:addOption(tr('Copy message'), function() g_window.setClipboardText(text) end)
|
||||||
menu:addOption(tr('Select all'), function() label:selectAll() end)
|
menu:addOption(tr('Select all'), function() label:selectAll() end)
|
||||||
|
|
Loading…
Reference in New Issue