Processing.py-Bugs
Processing.py-Bugs copied to clipboard
Keys "stick" after selectInput/selectOutput/selectFolder
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
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