Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

196
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda