Skip to content

Instantly share code, notes, and snippets.

@7Hazard
Created March 25, 2017 12:51
Show Gist options
  • Save 7Hazard/4c6a767495e33dce02f473cc9b85d9a2 to your computer and use it in GitHub Desktop.
Save 7Hazard/4c6a767495e33dce02f473cc9b85d9a2 to your computer and use it in GitHub Desktop.
A general class to use for CEF Windows,
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