Recommended Posts

Boa noite pessoal,

Pense na seguinte situação:

Voce tem os resources A, B e C, todos eles utlizam  browser, cada um com um fim especifico para o sistema. Para manter tudo funcionando perfeitamente, sem um click interferir em 2 browser ao mesmo tempo foi integrado o focusBrowser, mas isso me causou um outro problema que é "Eu preciso saber qual browser está com o focus no momento indepente do resource que esteja com ele e salvar o elemento dele para assim que eu fechar o browser atual retornar o focus pro anterior".

Vou postar a classe do browser que criei, e duas prints dos sistemas.

se alguem tiver uma solução simples que me atenda para um grande numero de browsers eh nois.

browser = {}
browser.__index = browser
function browser.create(x,y,w,h,localy,url)
    local self = setmetatable({},browser)
	self.x = x
	self.y = y
	self.w = w
	self.h = h
	self.url = url
	self.tick = getTickCount()
	self.element = createBrowser(self.w,self.h,localy,true)
	self.init = function() self:setUrl(url) end
	self.cursorMove = function(_,_,x,y) if self.element:isFocused() then self:onCursorMove(x,y) end end
	self.scrol = function(key) if self.element:isFocused() then self:key(key) end end
	self.onClick = function(button,state) if self.element:isFocused() then self:click(button,state) end end
	addEventHandler("onClientClick",root,self.onClick)
	addEventHandler("onClientKey",root,self.scrol)
	addEventHandler("onClientBrowserCreated",self.element,self.init)
	addEventHandler("onClientCursorMove",root,self.cursorMove)
	return self
end
function browser:render()
    local posX,posY,alpha = self.x,self.y,1
	dxDrawImage(posX,posY,self.w,self.h,self.element,0,0,0,tocolor(255,255,255,255*alpha))
end
function browser:setUrl(url)
	self.element:loadURL(url,"",false)
	self:requestFocus(true)
end
function browser:requestFocus(bool)
	if bool then
		focusBrowser(self.element)
	else
		focusBrowser(nil)
	end
end
function browser:execJS(string)
	executeBrowserJavascript(self.element,string)
end
function browser:checkPageName(name)
	if string.find(self.element:getURL():lower(),name,1,true) then
		return true
	end
	return false
end
function browser:key(key)
	if key == "mouse_wheel_down" then
		self.element:injectMouseWheel(-40,0)
	elseif key == "mouse_wheel_up" then
		self.element:injectMouseWheel(40,0)
	end
end
function browser:onCursorMove(x,y)
	local posX,posY = self.x,self.y
	self.element:injectMouseMove(x-posX,y-posY)
end
function browser:click(button,state)
	if state == "down" then
		self.element:injectMouseDown(button)
	else
		self.element:injectMouseUp(button)
	end 
end
function browser:getUrl()
	return self.element.url
end
function browser:destroy()
	removeEventHandler("onClientClick",root,self.onClick)
	removeEventHandler("onClientKey",root,self.scrol)
	removeEventHandler("onClientBrowserCreated",self.element,self.init)
	removeEventHandler("onClientCursorMove",root,self.cursorMove)
	self.element:destroy()
    setmetatable(self,nil)
end

mta-screen_2020-03-24_23-31-56.png?dl=1mta-screen_2020-03-24_23-32-59.png?dl=1

Share this post


Link to post
Posted (edited)

Isso é painel em HTML?

Edited by Lord Henry

Share this post


Link to post
7 minutes ago, Lord Henry said:

Isso é painel em HTML?

sim

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.