IsBrowserFocused: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (localPlayer is a predefined variable)
(Deleted needs example and changed format of example)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Client function}}
{{Client function}}
{{Needs Example}}
This function checks if a browser is focused.
This function checks if a browser is focused.


Line 17: Line 16:


==Example==
==Example==
This example creates a browser. If you press left control it will output to chatbox if the browser is focused or not.
<section name="Example" class="client" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
local theBrowser = guiCreateBrowser ( 150, 150, 1280, 720, true, false, false)
local theBrowser = guiCreateBrowser ( 150, 150, 1280, 720, true, false, false)
addEventHandler("onClientKey", localPlayer, function(button, state) -- adds the event handler.
addEventHandler("onClientKey", localPlayer,
if button == "lctrl" and state = "down" then -- if the pressed key is lctrl and the state is down then we will check is the browser focused or not.  
function(button, state) -- adds the event handler.
  if isBrowserFocused(theBrowser) then
if button == "lctrl" and state = "down" then -- if the pressed key is lctrl and the state is down then we will check is the browser focused or not.  
    outputChatbox("the browser is focused.") -- if the browser is focused then we will write this to chatbox.
if isBrowserFocused(theBrowser) then
  else
outputChatbox("the browser is focused.") -- if the browser is focused then we will write this to chatbox.
      outputChatbox("the browser is not focused.")-- if the browser is not focused then we will write this to chatbox.
else
  end
outputChatbox("the browser is not focused.")-- if the browser is not focused then we will write this to chatbox.
end
end
end)
end
end
)
</syntaxhighlight>
</syntaxhighlight>
</section>


==See Also==
==See Also==
{{CEF_functions}}
{{CEF_functions}}

Revision as of 03:29, 13 September 2017

This function checks if a browser is focused.

Syntax

bool isBrowserFocused ( browser webBrowser )

OOP Syntax Help! I don't understand this!

Method: browser:isFocused(...)


Required arguments

  • webBrowser: The browser

Returns

Returns true if the browser is focused, false otherwise and nil if invalid arguments were passed.

Example

This example creates a browser. If you press left control it will output to chatbox if the browser is focused or not.

Click to collapse [-]
Example
local theBrowser = guiCreateBrowser ( 150, 150, 1280, 720, true, false, false)
addEventHandler("onClientKey", localPlayer,
	function(button, state)  -- adds the event handler.
		if button == "lctrl" and state = "down" then -- if the pressed key is lctrl and the state is down then we will check is the browser focused or not. 
			if isBrowserFocused(theBrowser) then
				outputChatbox("the browser is focused.") -- if the browser is focused then we will write this to chatbox.
			else
				outputChatbox("the browser is not focused.")-- if the browser is not focused then we will write this to chatbox.
			end
 		end
	end
)

See Also