Skip to content
Snippets Groups Projects
Commit 4e280783 authored by DarkGod's avatar DarkGod
Browse files

Added an icon to webviews to copy the current URL to clipboard

parent 092c0819
No related branches found
No related tags found
No related merge requests found
game/engines/default/data/gfx/copy-icon.png

907 B

......@@ -195,8 +195,19 @@ function _M:webPopup(url)
local d = new(url, game.w * 0.9, game.h * 0.9)
local w = require("engine.ui.WebView").new{width=d.iw, height=d.ih, url=url, allow_downloads={addons=true, modules=true}}
if w.unusable then return nil end
local b = require("engine.ui.ButtonImage").new{no_decoration=true, alpha_unfocus=0.5, file="copy-icon.png", fct=function()
if w.cur_url then
local url = w.cur_url:gsub("%?_te4&", "?"):gsub("%?_te4", ""):gsub("&_te4", "")
core.key.setClipboard(url)
print("[WEBVIEW] url copy", url)
self:simplePopup("Copy URL", "URL copied to your clipboard.")
end
end}
w.on_title = function(title) d:updateTitle(title) end
d:loadUI{{left=0, top=0, ui=w}}
d:loadUI{
{left=0, top=-b.h / 2, ui=b},
{left=0, top=0, ui=w},
}
d:setupUI()
d.key:addBind("EXIT", function() game:unregisterDialog(d) end)
game:registerDialog(d)
......
......@@ -69,6 +69,7 @@ function _M:generate()
Dialog:webPopup(url, w, h)
end end,
on_loading = function(url, status)
self.cur_url = url
self.loading = status
end,
on_crash = function()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment