selectOutput() minimizes sketch window

edited February 2018 in Questions about Code

I've created a sketch that allows you to export an .obj file to a user specified destination. Everything is working great except for the fact that when the selectOutup() function is called the sketch window gets minimized. The file browser window comes up fine and when you save the file or cancel the operation the sketch reappears, but this behavior drives me nuts. It also has other unwanted consequences with my controlP5 elements and camera perspective.

Here is the code in case it's helpful in some way:

void openExportDialog()
{
  exportOBJBang.setBroadcast(false);
  File temp = new File("new_terrain.obj");
  selectOutput("SELECT A DESTINATION:", "exportOBJ", temp);
}

void exportOBJ(File selection)
{
  if(selection == null)
    return;
  else
  {
    String tempName = selection.getAbsolutePath();
    if(tempName.endsWith(".obj"))
      fileName = tempName;
    else
      fileName = tempName + ".obj";
    generateOBJ = true;
  }
}

Does anyone know a way to prevent this from happening?

Thanks!

Answers

  • Answer ✓

    https://github.com/processing/processing/blob/master/core/src/processing/core/PApplet.java#L6462

    One possible solution is to use all the parameters when calling selectOutput() function like this:

    selectOutput("SELECT A DESTINATION:", "exportOBJ", temp,this,null,null);

    Just to confirm, you set your renderer to P3D and your OS is Windows?

    Kf

  • Thanks for the suggestion @kfrajer! I am using the P3D renderer and am on Windows 10.

    Your solution absolutely works in terms of preventing sketch minimization, but now a new problem has arisen in that the browser window is opened behind the sketch. It's totally covered sometimes and there is no clear sign that it's even been opened.

    It was listed as a bug on the Processing repo: https://github.com/processing/processing/issues/3775

    Here are the key posts as to what the solution was: window_behind_sketch

    So it turns out that my initial bother was their fix for this other issue. I'm not sure which I prefer. Probably minimization, but neither is ideal. Hahaha! :P

    Thanks for your help!

Sign In or Register to comment.