Giter Club home page Giter Club logo

Comments (2)

HazelNutHoney avatar HazelNutHoney commented on June 27, 2024

A fix for this is in the index.js in the custom-electron-titlebar/titlebar folder in this.currentOptions under the last option which is tooltips for me

tooltips: {
     close: 'Close',
     maximize: 'Maximize',
     minimize: 'Minimize',
     restoreDown: 'Restore Down'
},

then add

minWidth: 400,
minHeight: 270,

then in the same file in the setupMenubar function located at line 157 for me add

_get__("electron_1").ipcRenderer.send('window-set-minimumSize', this.currentOptions.minWidth, this.currentOptions.minHeight)

at the bottom of the function under (0, _get__("dom_1").append)(this.titlebar, this.menuBarContainer); in the options.d.ts file located in cusotm-electron-titlebar/titlebar add

/**
* Controls the Minimum Width the user is allowed to resize the window to.
* **The default is 400*
*/
minWidth?: 400,

/**
* Controls the Minimum Height the user is allowed to resize the window to.
* **The default is 270*
*/
minHeight?: 270,

under the tooltips defintion, and lastly in the custom-electron-titlebar/main in setup-titlebar.js add

ipcMain.on('window-set-minimumSize', (event, width, height) => {
    const window = BrowserWindow.fromWebContents(event.sender);
    /* eslint-disable indent */
    if (window) {
      console.log(width, height);
      window?.setMinimumSize(width, height);
    }
  });

under

ipcMain.on('window-event', (event, eventName) => {
    const window = BrowserWindow.fromWebContents(event.sender);
    /* eslint-disable indent */
    if (window) {
      switch (eventName) {
        case 'window-minimize':
          window?.minimize();
          break;
        case 'window-maximize':
          window?.isMaximized() ? window.unmaximize() : window?.maximize();
          break;
        case 'window-close':
          window?.close();
          break;
        case 'window-is-maximized':
          event.returnValue = window?.isMaximized();
          break;
        default:
          break;
      }
    }
  });

To use this in your preload.js file in the titlebar options add a minWidth and minHeight like you would normally to the mainWindow just this time its in titlebarOptions instead an example of this in the options is

window.addEventListener("DOMContentLoaded", () => {
    // Title bar implementation
    new Titlebar({
        minWidth: 1080,
        minHeight: 720,
    });
});

from custom-electron-titlebar.

HazelNutHoney avatar HazelNutHoney commented on June 27, 2024

@AlexTorresDev I created a pr that fixes this issue

from custom-electron-titlebar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.