Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

197
Vistas
JavaScript: Use two seperate dialogues in the same nodeJS electron controller (CLOSED)

I want to create two seperate electron dialogs, one for APK file selection, and one for Directory selection so I can select a decompiled APK folder.

Using one dialog for both File Selection and Directory Selection at the same time, cannot be done on both Linux & Windows, unlike how it can on MacOS.

So after some time talking with the devs over at github.com/electron/electron, they have told me that it is possible to use 2 seperate dialogs in the same JavaScript file that I use as the main controller to my Linux desktop app, as a workaround to this for Linux & Windows.

The devs pointed me to this page here at electronjs.org, but unfortunately I am having trouble understanding some of it, so I've ended up here at stackoverflow.

The code I've managed to produce so far is below, any help on this would be appreciated.

// First dialog for File Selection | This works fine
$appCtrl.BrowseApk = () => {
    dialog.showOpenDialog({'File browser'}, {

        properties: ['openFile']
    }).then(result => {

        if(result.canceled) {

            $appCtrl.Log("No file selected");
        } else {

            $appCtrl.Log("File selected" + result.filePaths[0]);
            readFile(result.filePaths[0]);
        }
    }).catch(() => {
        $appCtrl.Log("No file selected");
    })

    function readFile(filepath) {
        $appCtrl.filePath = filepath;
        $appCtrl.$apply();
    })
            

    // Second Dialog for Folder Selection | This breaks my electron UI
    $appCtrl.BrowseFolder = () => {
    dialog.showOpenDialog({'Folder browser'}, {

        properties: ['openDirectory']
    }).then(result => {

        if(result.canceled) {

            $appCtrl.Log("No directory selected");
        } else {

            $appCtrl.Log("Directory selected" + result.filePaths);
            readFile(result.filePaths);
        }
    }).catch(() => {
        $appCtrl.Log("No directory selected");
    })

    function readFile(filepath) {
        $appCtrl.filePath = filepath;
        $appCtrl.$apply();
    })     
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Problem solved! all I had to do was the following below.

//function to open the dialog and an choose apk file
  $appCtrl.BrowseApk = () => {
      dialog.showOpenDialog({ 
          properties: ['openFile'], 
          title: 'Choose APK to bind', 
          buttonLabel: 'Select APK',
          filters: [
              { name: 'Android APK', extensions: ['apk'] } // only select apk files
          ]
      }).then(result => { 
          if(result.canceled) {
              $appCtrl.Log("No file selected"); //if user cancels the dialog
          } else {
              $appCtrl.Log("File choosen  " + result.filePaths[0]); //if user selects an APK file
              readFile(result.filePaths[0]); 
          }
      }).catch(() => { 
          $appCtrl.Log("No file selected"); 
      })

      function readFile(filepath) {
          $appCtrl.filePath = filepath;
          $appCtrl.$apply();
      }
  }
  // function to select decompiled APK folder
  $appCtrl.BrowseFolder = () => { 
      dialog.showOpenDialog({
          properties: ['openDirectory'],
          title: 'Choose decompiled APK folder',
          buttonLabel: 'Select Folder',
          filters: [
              { name: 'Folders', extensions: ['*'] }
          ]
      }).then(result => {
          if(result.canceled) {
              $appCtrl.Log("No folder selected");
          } else {
              $appCtrl.Log("Folder choosen " + result.filePaths[0]); //if user selects a Decompiled APK file
              readFile(result.filePaths[0]);
          }
      }).catch(() => {
          $appCtrl.Log("No folder selected");
      })
      
      function readFile(filepath) {
        $appCtrl.filePath = filepath;
        $appCtrl.$apply();
    }

  }
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda