From 7ec5e1ab2ac0ac14f12d875ef2490b959346aed4 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Thu, 23 Mar 2023 14:45:46 -0400 Subject: [PATCH] Made the buttons in the file browser example work --- elements/file/directory.go | 5 ++++- examples/fileBrowser/main.go | 15 +++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/elements/file/directory.go b/elements/file/directory.go index 7707aa6..dee8eeb 100644 --- a/elements/file/directory.go +++ b/elements/file/directory.go @@ -137,7 +137,10 @@ func (element *DirectoryView) Update () error { element.children[index].DirEntry = entry } - element.redoAll() + if element.core.HasImage() { + element.redoAll() + element.core.DamageAll() + } return err } diff --git a/examples/fileBrowser/main.go b/examples/fileBrowser/main.go index 12bfe0c..6c62da1 100644 --- a/examples/fileBrowser/main.go +++ b/examples/fileBrowser/main.go @@ -42,12 +42,16 @@ func run () { scrollContainer := containers.NewScrollContainer(false, true) directoryView, _ := fileElements.NewDirectoryView(homeDir, nil) - choose := func (filePath string) { - directoryView.SetLocation(filePath, nil) + updateStatus := func () { + filePath, _ := directoryView.Location() directory.SetLocation(filePath, nil) locationInput.SetValue(filePath) baseName.SetText(filepath.Base(filePath)) } + choose := func (filePath string) { + directoryView.SetLocation(filePath, nil) + updateStatus() + } directoryView.OnChoose(choose) locationInput.OnEnter (func () { choose(locationInput.Value()) @@ -55,12 +59,19 @@ func run () { choose(homeDir) backButton.OnClick (func () { directoryView.Backward() + updateStatus() }) forwardButton.OnClick (func () { directoryView.Forward() + updateStatus() }) refreshButton.OnClick (func () { directoryView.Update() + updateStatus() + }) + upwardButton.OnClick (func () { + filePath, _ := directoryView.Location() + choose(filepath.Dir(filePath)) }) controlBar.Adopt(backButton, false)