ResizeBrowser: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Client function}} {{New feature/item|3.0160|1.5.3|9912| Allows resizing of CEF browsers at runtime. }} ==Syntax== <syntaxhighlight lang="lua"> bool resizeBrowser(browser webBrowse...")
 
m (Link to the Romanian translation of this page added.)
 
(9 intermediate revisions by 7 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Client function}}
{{Client function}}
{{New feature/item|3.0160|1.5.3|9912|
{{New feature/item|3.0153|1.5.3|9912|
Allows resizing of CEF browsers at runtime.
Allows resizing of CEF browsers at runtime.
}}
}}
{{Warning|Do '''not''' use this function with [[onClientRender]] as it re-creates the underlying texture internally (which is an expensive operation).|true}}


==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool resizeBrowser(browser webBrowser, float width, float height)
bool resizeBrowser ( browser webBrowser, float width, float height )
</syntaxhighlight>
</syntaxhighlight>


Line 19: Line 21:


==Example==
==Example==
{{Example}}
Example for resize browser by command.
<syntaxhighlight lang="lua">
 
screenWidth, screenHeight = guiGetScreenSize()
initBrowser = guiCreateBrowser(0, 0, screenWidth, screenHeight, true, true, false)
addCommandHandler("resize",
function ( cmd, width, height )
local browser = guiGetBrowser(initBrowser)
local width, height = tonumber(width), tonumber(height)
resizeBrowser( browser, width, height )
end
)
 
</syntaxhighlight>


==See Also==
==See Also==
{{CEF_functions}}
{{CEF_functions}}
[[hu:resizeBrowser]]
[[RO:resizeBrowser]]

Latest revision as of 14:27, 8 April 2020

Allows resizing of CEF browsers at runtime.

Dialog-warning.png Warning: Do not use this function with onClientRender as it re-creates the underlying texture internally (which is an expensive operation).

Syntax

bool resizeBrowser ( browser webBrowser, float width, float height )

Required Arguments

  • webBrowser: The browser you want to resize.
  • width: The new width of the browser.
  • height: The new height of the browser.

Returns

Returns true if the browser is resized successfully, false if there's something wrong.

Example

Example for resize browser by command.


screenWidth, screenHeight = guiGetScreenSize()
initBrowser = guiCreateBrowser(0, 0, screenWidth, screenHeight, true, true, false)
addCommandHandler("resize",
	function ( cmd, width, height )
		local browser = guiGetBrowser(initBrowser)
		local width, height = tonumber(width), tonumber(height)
		resizeBrowser( browser, width, height )
	end
)

See Also