* Create a named window * MARK: cNamed * @param {string} winName window * @param {Object} windowArgs arguments for window callback * @param {?function} extraCallback additional callback
(winName, windowArgs, extraCallback = null)
| 849 | * @param {?function} extraCallback additional callback |
| 850 | */ |
| 851 | createNamedWindow(winName, windowArgs, extraCallback = null) { |
| 852 | const subWinDef = this.winDefs[winName] |
| 853 | const thisWinName = subWinDef.winName |
| 854 | |
| 855 | if ( this.isValid(thisWinName) ) { |
| 856 | if ( this.win[thisWinName].isMinimized() ) { this.win[thisWinName].restore() } |
| 857 | this.win[thisWinName].focus() |
| 858 | if ( subWinDef.refocusCallback ) { |
| 859 | subWinDef.callback(windowArgs) |
| 860 | if ( typeof extraCallback === 'function' ) { extraCallback() } |
| 861 | } |
| 862 | return |
| 863 | } |
| 864 | |
| 865 | this.win[thisWinName] = this.createSubWindow(thisWinName, subWinDef.subWindowArgs) |
| 866 | |
| 867 | this.win[thisWinName].webContents.on('did-finish-load', async () => { |
| 868 | setTimeout(() => { |
| 869 | subWinDef.callback(windowArgs) |
| 870 | |
| 871 | if ( typeof extraCallback === 'function' ) { extraCallback() } |
| 872 | }, 250) |
| 873 | |
| 874 | if ( this.#debug && this.#dev.has(thisWinName) && ( !Object.hasOwn(this.devTools, thisWinName) || this.devTools[thisWinName] === null ) ) { |
| 875 | this.devTools[thisWinName] = this.createSubWindow('devtools', { |
| 876 | show : true, |
| 877 | useCustomTitle : false, |
| 878 | }) |
| 879 | this.win[thisWinName].webContents.setDevToolsWebContents(this.devTools[thisWinName].webContents) |
| 880 | this.win[thisWinName].webContents.openDevTools({ |
| 881 | activate : false, |
| 882 | mode : 'detach', |
| 883 | }) |
| 884 | this.devTools[thisWinName].minimize() |
| 885 | |
| 886 | setTimeout(() => { |
| 887 | if ( this.isValid(thisWinName) ) { |
| 888 | this.devTools[thisWinName].setTitle(`DevTools - ${thisWinName} - ${subWinDef.HTMLFile}`) |
| 889 | } |
| 890 | }, 1500) |
| 891 | } |
| 892 | }) |
| 893 | |
| 894 | this.win[thisWinName].loadFile(path.join(this.#path.render, subWinDef.HTMLFile)) |
| 895 | |
| 896 | this.win[thisWinName].on('closed', () => { |
| 897 | this.destroyAndFocus(thisWinName) |
| 898 | if ( typeof subWinDef.extraCloseFunc === 'function' ) { |
| 899 | subWinDef.extraCloseFunc() |
| 900 | } |
| 901 | if ( this.#debug && this.#dev.has(thisWinName) && this.devTools[thisWinName] !== null && !this.devTools[thisWinName].isDestroyed() ) { |
| 902 | this.devTools[thisWinName].close() |
| 903 | this.devTools[thisWinName] = null |
| 904 | } |
| 905 | |
| 906 | }) |
| 907 | |
| 908 | if ( subWinDef.handleURLinWin ) { |
no test coverage detected