Processing.py-Bugs icon indicating copy to clipboard operation
Processing.py-Bugs copied to clipboard

Keys "stick" after selectInput/selectOutput/selectFolder

Open JulGvoz opened this issue 6 years ago • 1 comments

When calling selectInput/selectOutput/selectFolder, when detecting key presses in draw(), the sketch thinks that keys are still being pressed even though they are no longer pressed I've put together a small sketch to show this effect:

resolvedSaveLoad = True
alreadyPressed = False

def setup():
    pass

def fileSelected(selection):
    global resolvedSaveLoad
    if selection == None:
        print("Window was closed or the user hit cancel.")
    else:
        print("User selected " + selection.getAbsolutePath())
    resolvedSaveLoad = True

def draw():
    global alreadyPressed, resolvedSaveLoad
    print(keyPressed, key, alreadyPressed, resolvedSaveLoad, millis())
    if keyPressed and not alreadyPressed and resolvedSaveLoad:
        
        alreadyPressed = True
        
        if key == 's':
            resolvedSaveLoad = False
            selectOutput("Select where to save", "fileSelected")
    
    if not keyPressed:
        alreadyPressed = False

JulGvoz avatar Aug 14 '19 09:08 JulGvoz

Possibly unrelated, but when stopping the sketch while the selectInput/selectOutput/selectFolder window is open, and then selecting a file/folder or cancelling, the sketch still executes fileSelected(), so the sketch "comes back from the dead" a little

JulGvoz avatar Aug 14 '19 09:08 JulGvoz