Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trace Window? #27

Closed
Justinfront opened this issue Jan 5, 2017 · 1 comment
Closed

Trace Window? #27

Justinfront opened this issue Jan 5, 2017 · 1 comment

Comments

@Justinfront
Copy link

Currently when running electron I trace to the screen but that's kind of annoying as it tends to mess up the view.
It seems you can quite easily create a secondary window, I was wondering if ipc could be setup so that messages could be transfered between apps, seems there is an extern here but not sure on setup?
https://github.com/ciscoheat/haxe-js-kit/blob/master/js/atomshell/browserandwebpage/Ipc.hx
The concept is here:
electron/electron#991
I presume if I understood setting up the externs I could create a Tracer js something like...

import js.Browser.console;
import js.Browser.document;
import js.Browser.window;
import js.html.*;
import js.node.Ipc;
class Tracer {
    static var div: DivElement;
    static function main() {
        window.onload = function(){ 
            div = cast document.getElementById( 'traceInfo' );
            Ipc.on('my-msg', function(event, arg) {
                screenLog( arg );
                });
        }
    }
    public static function screenLog( d: Dynamic ){
        div.textContent += d;
    }
}

so my main class might change to something like.

import electron.main.*;
class Main {
    static function main() {
        electron.CrashReporter.start({
            companyName : "(not a company)",
            submitURL : "https://github.com/justinfront/hxelectron/issues"
        });
        electron.main.App.on( 'ready', function(e) {
            #if fullScreen
                var win: BrowserWindow = new BrowserWindow( { width: 800, height: 600, frame: false } );
                win.setFullScreen( true );
            #else
    			var win: BrowserWindow = new BrowserWindow( { width: 800, height: 600 } );
            #end
            win.on( BrowserWindowEvent.closed, function(e) {
                if( js.Node.process.platform != 'darwin' ) App.quit();
            });
            
            var win2: BrowserWindow = new BrowserWindow( { width: 300, height: 500, x: 0, y: 0 });
            win2.on( BrowserWindowEvent.closed, function(e) {
                if( js.Node.process.platform != 'darwin' ) App.quit();
            });
            win3.loadURL('file://' + js.Node.__dirname + '/tracer.html' );
            win.loadURL( 'file://' + js.Node.__dirname + '/app.html' );
        });
    }
}

Then in your app code

static inline function tracer( d: Dynamic ){
    Ipc.send('my-msg', d );
}

I managed to get Neko to run from my electron app perhaps this is also something to explore, perhaps if HL worked more easily on mac it might be interesting to try or python!
https://www.fyears.org/2015/06/electron-as-gui-of-python-apps.html

Might be nice to have a optional trace window out of the box, and optional wrapper for running HL/Neko/Python code? What do you think Franco is it beyond the scope of this github?

@tong
Copy link
Owner

tong commented Jul 19, 2018

Yes, out of scope.
Also why not use devtools (https://electronjs.org/docs/tutorial/application-debugging) ?

@tong tong closed this as completed Jul 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants