From 35caf71f31eafe449d679462d281970faff918c3 Mon Sep 17 00:00:00 2001 From: Ivan Voras Date: Sun, 3 Mar 2024 22:01:24 +0100 Subject: [PATCH 1/4] Submitting the saveName behaves as if the save button is clicked --- dialog/file.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dialog/file.go b/dialog/file.go index cce25820e6..64ec2a93bf 100644 --- a/dialog/file.go +++ b/dialog/file.go @@ -101,6 +101,9 @@ func (f *fileDialog) makeUI() fyne.CanvasObject { } } saveName.SetPlaceHolder(lang.L("Enter filename")) + saveName.OnSubmitted = func(s string) { + f.open.OnTapped() + } f.fileName = saveName } else { f.fileName = widget.NewLabel("") From e0f3467f92b8e4faa55f7522a584e7705758294f Mon Sep 17 00:00:00 2001 From: Ivan Voras Date: Sun, 3 Mar 2024 22:03:10 +0100 Subject: [PATCH 2/4] Focusing on the fileName Entry as soon as the dialog is shown Not terribly happy with the need to use Sleep() to do this asynchronously --- dialog/file.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dialog/file.go b/dialog/file.go index 64ec2a93bf..5317e5de7b 100644 --- a/dialog/file.go +++ b/dialog/file.go @@ -8,6 +8,7 @@ import ( "runtime" "strings" "sync" + "time" "fyne.io/fyne/v2" "fyne.io/fyne/v2/container" @@ -647,6 +648,13 @@ func showFile(file *FileDialog) *fileDialog { d.setLocation(file.effectiveStartingDir()) d.win.Show() + if file.save { + // Focus on the filename Entry as soon as the dialog is shown + go func() { + time.Sleep(25 * time.Millisecond) + file.dialog.win.Canvas.Focus(file.dialog.fileName.(*widget.Entry)) + }() + } return d } From dd3172c6cef823bc63aeafeddf27e094dd46c6fc Mon Sep 17 00:00:00 2001 From: Ivan Voras Date: Mon, 4 Mar 2024 22:33:51 +0100 Subject: [PATCH 3/4] References d instead of file.dialog --- dialog/file.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/dialog/file.go b/dialog/file.go index 5317e5de7b..6818704f9e 100644 --- a/dialog/file.go +++ b/dialog/file.go @@ -8,7 +8,6 @@ import ( "runtime" "strings" "sync" - "time" "fyne.io/fyne/v2" "fyne.io/fyne/v2/container" @@ -649,11 +648,8 @@ func showFile(file *FileDialog) *fileDialog { d.setLocation(file.effectiveStartingDir()) d.win.Show() if file.save { - // Focus on the filename Entry as soon as the dialog is shown - go func() { - time.Sleep(25 * time.Millisecond) - file.dialog.win.Canvas.Focus(file.dialog.fileName.(*widget.Entry)) - }() + // Focus on the fileName Entry as soon as the dialog is shown + d.win.Canvas.Focus(d.fileName.(*widget.Entry)) } return d } From 58ad37d569eb68de9c11608d0a8da8fdbdfb0831 Mon Sep 17 00:00:00 2001 From: Ivan Voras Date: Tue, 5 Mar 2024 00:07:20 +0100 Subject: [PATCH 4/4] Removed the comment --- dialog/file.go | 1 - 1 file changed, 1 deletion(-) diff --git a/dialog/file.go b/dialog/file.go index 6818704f9e..1acbfab2dc 100644 --- a/dialog/file.go +++ b/dialog/file.go @@ -648,7 +648,6 @@ func showFile(file *FileDialog) *fileDialog { d.setLocation(file.effectiveStartingDir()) d.win.Show() if file.save { - // Focus on the fileName Entry as soon as the dialog is shown d.win.Canvas.Focus(d.fileName.(*widget.Entry)) } return d