Ko/dialogs filepicker() dialog and callback file access

My limited knowledge of JavaScript may be one reason why I’m wondering how to properly use a callback function in require( “ko/dialogs” ) and be able to do something with the chosen file. When writing some Firefox and Chrome extensions recently, the canonical way to do callbacks was apparently in the form of an anonymous function, and that always worked fine. But I’m not sure how to do it with the Komodo IDE SDK. Here was my first try:

var d = require( "ko/dialogs" );
d.filepicker( "title", function() { alert( "callback was called" ); }, {} );

A function variable (my apologies if I am misremembering the term) behaves the same:

var f = function() { alert( "callback was called" ); };
d.filepicker( "title", f, {} );

Both techniques result in a file selection dialog. But if a file is chosen and the “Ok” button is clicked, the dialog box does not go away. To make it go away, one must click the “Cancel” button and thus no file is chosen. Either way, I’m not sure what the callback function should look like in order to process the file, assuming one can get the dialog box to work. Any ideas?

I cannot reproduce your problem, with your code when I press OK an alert dialog shows as expected.

Can you reproduce your issue in safe-mode?

In safe mode, the behavior is a bit different (and I have no idea why): When I choose a file and then click the “Ok” button, the file picker dialog does not go away, but the callback alert pops up behind it. I then have to click the “Cancel” button to make the file picker dialog go away, so I can then dismiss the alert.

By accident I discovered some odd behavior: If I switch to another app during the process, and then switch back, the file picker dialog is its own task (a Windows task), separate from Komodo IDE. If I switch to it and then click the “Ok” button, it takes me back to Komodo IDE, and the file picker dialog is still there, with the callback alert popped up behind it.

Would it help if the callback function actually did something with the file (regardless of how minor)? I still don’t know how to have the callback refer to the file.