Renoise.app():prompt_for_path(dialog_title), return "cancel" string?


(Raul (ulneiz)) #1

Renoise 3.1.1 x64 W10 x64:

I think there is a small problem with the following case of aplication:

– Opens a modal dialog to query an existing directory from the user.
renoise.app():prompt_for_path(dialog_title)
-> [valid path or empty string]

There is no way to return nil or a boolean, or string “Cancel” to identify if the user presses the “Cancel” button.

The specific problem is that, apparently the return of an empty string (""), returns the path C:/, a valid path. The issue is that some form of being able to continue with the function without resorting to the empty string is necessary. What happens is that if you use the empty string to continue with the function, the “Accept” button will do nothing, if you use the empty string as a condition to continue with the function (if path == “” then …)

The expected thing would be, to return

  1. non-empty string or empty string (both)
  2. nil …or “cancel” string.

That is, it is not possible to use the empty string for the Cancel button. If so, the OK button will not be able to take the empty string as a possible route. It forces the user to change the route in the pop-up window, when it should not be like that. C: / is also a valid path to save folders.


(taktik) #2

Not sure I get it. The function returns an empty string when the user pressed cancel, so you can identify already if the user cancelled the dialog.


(Raul (ulneiz)) #3

I think that, if the user does not change the path in the window, simply click on open the dialog and then “Accept”, returns an empty string, which by default takes “C: /” (which is to save on this computer). Then, you need another way to alert the function when you press the cancel button.

To test it open this dialog box to determine the path and simply press the “Accept” button without changing the path. If you print in the terminal it will return an empty string, that is, nothing.

local function mpt()
  local prompt=renoise.app():prompt_for_path("test")
  print("prompt:",prompt)  --??? ... prompt = a empty string, pressing Accept
  print("empty_string:","")
end
mpt()

That is, by clicking “Accept”, should never return an empty string, should always return a valid route.


(ffx) #4

i like “false” btw. Best comment ever.


(taktik) #5

It can’t, if you for example select the “Libraries” folder or “My Computer” in the dialog.

But there indeed is a little quirk on Windows 8 (that’s what you’re using, right?) in the Windows directory prompt: It should return “C: /”, when initially the “C: /” drive is selected. Will fix that.


#6

Top part of Raul’s initial post:


(Raul (ulneiz)) #7

I think I’m using the latest updated version of Windows 10 x64 (1809, version 17763.437).

Maybe it’s a specific case of this operating system and I think the operating system works the way it should. That is, if the user opens the dialog box and clicks “OK” and does nothing else, the function returns an empty string, and in this case, Windows 10 will take C: /, because the user has not changed the path .

Then the empty string does not cover all cases to use it as an “Cancel” indicator.

As far as I know there are 4 possible cases:

  1. “Cancel”. (work ok)
    image

  2. “Accept” with an invalid route. The window warns the user that he must enter a valid route. It does not allow to advance while that does not happen. (work ok)
    image

  3. “Accept” with a valid route. In this case the user must select a route different from the default one. (work ok)
    image

  4. "Accept" without the user changing the path in the dialog box. In this case it is where the problem is, because it returns the empty string, when it should return the path “C: /” or return something other than an empty string. (problem)
    image

Conclusion, there is a case (4) that returns an empty string when the user clicks “Accept”. Then, the empty string does not cover all cases for the “Cancel” button. That’s why I suggested another way to detect when the user clicks “Cancel”, or to fix the specific case.

This is a bit annoying because it is quite common for the user to open the dialog box and press “Accept” without changing the path and then the function does not do anything, it does not save a folder or a file, which is what it should do, because the condition of the empty string is used for “Cancel”: if (prompt == “”) then


(Raul (ulneiz)) #8

This could be a typical use function to save an existing folder inside the tool. It could be used to reproduce the problem:

local function chd_backup_all_banks()
  --check if exist main_folder
  local origin_main_folder="chord_banks"
  if io.exists(origin_main_folder) then
    --create destiny main folder
    local path=rna:prompt_for_path("Choose a destination path to save a backup folder of all the banks.")
    print("path",path)
    if (path=="") then
      return --to Cancel button
    else
      --to Accept button
    end
  end
end

Obviously, the folder to be copied must already exist.


(taktik) #9

I see. Sorry for the confusion.

“My Computer” (“Este equipo”) is not “C:/” - it’s a node which lists all locally connected hard drives. It’s not a valid file system path. Just like “Libraries” (“Bibliotecas”) and some other nodes.

So it should not be possible to select such items and hit “Ok” (Aceptar), so you are forced to select a valid folder or should explicitly cancel the dialog.

The dialog is a standard Windows Explorer dialog. We haven’t made it. But I’ll check if we nevertheless can somehow change/improve this.


(Raul (ulneiz)) #10

Thanks!

I suppose that the correct operation would be, if the user selects “Este Equipo” or “Librerías” (or any similar case) the pop-up window of “Invalid path” should appear when clicking Accept, not allowing it to return an empty string…