Last active
March 25, 2017 12:54
-
-
Save 7Hazard/ace1bf7f53351ffbe7c52dfd3896b021 to your computer and use it in GitHub Desktop.
A general class to use for CEF Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Usage: | |
var cef = new CEFWindow("your/path/", local(bool), width, height, x, y); | |
*/ | |
class CEFWindow { | |
path; local; open; x; y; width; height; browser; | |
constructor(resourcePath, local, width, height, x, y) { | |
this.path = resourcePath; | |
this.local = local; | |
this.open = false; | |
this.x = x; | |
this.y = y; | |
this.width = width; | |
this.height = height; | |
} | |
show() { | |
if (this.open === false) { | |
this.open = true; | |
this.browser = API.createCefBrowser(this.width, this.height, this.local); | |
API.waitUntilCefBrowserInit(this.browser); | |
API.setCefBrowserPosition(this.browser, this.x, this.y); | |
API.loadPageCefBrowser(this.browser, this.path); | |
API.showCursor(true); | |
} | |
} | |
destroy() { | |
this.open = false; | |
API.destroyCefBrowser(this.browser); | |
API.showCursor(false); | |
} | |
eval(string) { | |
this.browser.eval(string); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment