selectInput() opens two dialog boxes when using OPENGL

Hi there,

I am writing a program which scrolls text across the screen and fades it in a certain way. It uses a separate Swing window with some sliders and buttons to change the parameters. I had quite some difficulty with selectInput(), which has changed quite a lot since Processing 1.5 (I had a bit of a break). The main issue I had was that the program would keep running while the dialogue box came up, and try to refer to the text file that hadn't been loaded yet because the file hadn't been chosen. I fixed this by putting the selectInput statement right at the start of setup, putting my call to initialize() (which is a function that loads all the strings into the arrays) in the selectInput() call, and also putting everything in draw() into an if block if(loadPath!=null) { draw stuff } Thus draw will not do anything until the loadPath has actually been chosen in the file dialogue box.

This works, but two dialog boxes come up instead of just one! You can still choose the file in one and cancel the other, but it's irritating. If I don't use OPENGL, i.e if I change size(800, 450, OPENGL) to size(800, 450), the double dialogue box problem goes away. But the OPENGL makes the sketch render more smoothly so I don't want to turn it off.

I'm using Processing 2.03, OSX 10.9.

Any suggestions would be greatly appreciated. I can post the code but the program is quite big....

Giles.

Answers

  • Answer ✓

    "I fixed this by putting the selectInput statement right at the start of setup"
    Again (and again), the first instruction of setup() should be a size() call.

    In any mode beside the default one (JAVA2D), instructions before size() are run twice...

  • Thanks, that fixed it. I put the selectInput() directly after size and all was good.

Sign In or Register to comment.