Jump to content

CEF


mommytellme

Recommended Posts

Hi, I started with the CEF and created the login panel, but if I try to call the JS-level event MTA using

mta.triggerEvent("onCEFLoginRegister"); 

, nothing happens. What am I doing wrong?

My code:

  
local sw,sh = guiGetScreenSize() 
  
local webView = guiCreateBrowser(0, 0, sw, sh, true, true, true) 
  
--function render () 
    --dxDrawImage(0, 0, sw, sh, webView) 
--end 
  
  
addEventHandler("onClientBrowserCreated", webView, 
     function() 
        loadBrowserURL(source, "http://mta/local/html/index.html") 
        focusBrowser(source) 
     end 
) 
  
  
addEventHandler("onCEFLoginRegister", root, 
    function () outputChatBox("beniz") end) 
  

Link to comment

Any errors if you open the html file in chrome/ie/edge in your js file?

Also, the trigger you're using. Are you sure you've initialized the mta variable? If you're using the javascript SDK, which I assume you do, you can also try to call the resource's function directly without the eventHandler trigger.

callFunction ( "resourceName", "functionName", returnFunction, errorFunction [, arguments... ] ); 

source; https://wiki.multitheftauto.com/wiki/Javascript_SDK

Link to comment

The Javascript SDK has nothing to do with CEF. It's part of the resource web access system.

Where exactly did you get the ReferenceError error message?

The problem is that you forgot adding the event before binding it using:

addEvent("onCEFLoginRegister") 

Link to comment

If you're not adding the event, the server's console should've thrown an error. Guess ThePiotrek did watch his console before coming here.

From the style that the error has been noted, it should be in his browser outside of MTA. Even though it does miss some things for a real console error from Javascript. It's not styled as an error from MTA either, so it could be IE/edge's console. Not sure how they build up their errors.

Link to comment
If you're not adding the event, the server's console should've thrown an error.

No. An error is only thrown when triggering an event to the server. mta.triggerEvent calls triggerEvent internally.

From the style that the error has been noted, it should be in his browser outside of MTA.

Yes, that's what I think either.

In general: Calling toggleBrowserDevTools opens the Chromium dev tools window which provides a proper console (remember to enable devmode using setDevelopmentMode(true,true) before though).

Link to comment
An error is only thrown when triggering an event to the server

Totally off-topic, last message from being off topic too. By triggereing a client sided event which hasn't been added, it also gets called. Just on the client's console ( debugscript ). Which in his case, probably, is the same location as the server.

The chromium dev tools could be the way he found the error, not sure how chromium builds up their errors. If it's the same way as Chrome, it doesn't really fit in there. I've been working with chromium a lot but I can't remember the way they build them up. Not even sure if they aren't just transforming the direct javascript error towards the console.

Link to comment

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.
×
×
  • Create New...