You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like the user to start at a certain directory, so to only traverse down the directory tree. However setting dialog.startDirectory has no effect. It always starts at Desktop in Windows. For OpenFileDialog setting dialog.directory works as expected, going straight to the preset directory. I started the test with an edited version of the example code.
Am I doing something wrong (I'm fairly new to Nim), or is this an issue ?
`
This example shows how to use the Open File and Save File As dialogs.
import nigui
app.init()
var window = newWindow()
var mainContainer = newLayoutContainer(Layout_Vertical)
window.add(mainContainer)
var buttons = newLayoutContainer(Layout_Horizontal)
mainContainer.add(buttons)
var textArea = newTextArea()
mainContainer.add(textArea)
I think I'm onto the reason it doesn't work. But I'm too new at Nim to try and correct it. I've had a look at the source code and saw this in windows/platform_impl.nim :
in the run method for OpenFile the dialog.directory has what I think is a pointer (line 535) ofn.lpstrInitialDir = dialog.directory.pUtf8ToUtf16()
in SelectDialog (line 556) dialog.selectedDirectory = ""
Shouldn't that be something like ofn.lpstrInitialDir = dialog.startdirectory.pUtf8ToUtf16()
I dare not change this myself in fear of breaking things... too new at this
I would like the user to start at a certain directory, so to only traverse down the directory tree. However setting dialog.startDirectory has no effect. It always starts at Desktop in Windows. For OpenFileDialog setting dialog.directory works as expected, going straight to the preset directory. I started the test with an edited version of the example code.
Am I doing something wrong (I'm fairly new to Nim), or is this an issue ?
`
This example shows how to use the Open File and Save File As dialogs.
import nigui
app.init()
var window = newWindow()
var mainContainer = newLayoutContainer(Layout_Vertical)
window.add(mainContainer)
var buttons = newLayoutContainer(Layout_Horizontal)
mainContainer.add(buttons)
var textArea = newTextArea()
mainContainer.add(textArea)
var button1 = newButton("Open ...")
buttons.add(button1)
button1.onClick = proc(event: ClickEvent) =
var dialog = newOpenFileDialog()
dialog.title = "Test Open"
dialog.multiple = true
dialog.directory = "D:\Software"
dialog.run()
textArea.addLine($dialog.files.len & " files selected")
if dialog.files.len > 0:
for file in dialog.files:
textArea.addLine(file)
var button2 = newButton("Select Directory ...")
buttons.add(button2)
button2.onClick = proc(event: ClickEvent) =
var dialog = SelectDirectoryDialog()
newSelectDirectory ?? -> doesn't work either
dialog.title = "Test Select Directory"
dialog.startdirectory = "C:\Users\Ivan"
check whether startdirectory is set properly
echo "startdirectory: ", dialog.startdirectory
dialog.run()
if dialog.selectedDirectory == "":
textArea.addLine("No directory selected")
else:
textArea.addLine(dialog.selectedDirectory)
window.show()
app.run()`
The text was updated successfully, but these errors were encountered: