Skip to content

Commit

Permalink
Fix EntryNavItem constructor function
Browse files Browse the repository at this point in the history
  • Loading branch information
oligo committed Oct 30, 2024
1 parent dbd97ff commit 92cc484
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
2 changes: 1 addition & 1 deletion example/basic/home.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func newHome(window *app.Window) *HomeView {
sidebar.AddSection(navi.SimpleItemSection(viewIcon, "Editor Example", EditorExampleViewID, false))
sidebar.AddSection(navi.SimpleItemSection(viewIcon, "File Explorer", ExplorerViewID, false))

fileTree := explorer.NewEntryNavItem("../../", nil, nil)
fileTree, _ := explorer.NewEntryNavItem("../../", nil, nil)
sidebar.AddSection(explorer.NewFileTreeNav(sidebar, "File Explorer", fileTree))

vm.Register(ExampleViewID, func() view.View { return NewExampleView(vm) })
Expand Down
14 changes: 3 additions & 11 deletions explorer/tree_style.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,12 @@ func (tn *FileTreeNav) Layout(gtx C, th *theme.Theme) D {
}

// Construct a file tree object that loads files and folders from rootDir.
// `skipFolders` allows you to specify folder name prefixes to exclude from the navigation.
// `menuOptionFunc` is used to define the operations allowed by context menu(use right click to active it).
// `onSelectFunc` defines what action to take when a navigable item is clicked (files or folders).
func NewEntryNavItem(rootDir string, menuOptionFunc MenuOptionFunc, onSelectFunc OnSelectFunc) *EntryNavItem {
func NewEntryNavItem(rootDir string, menuOptionFunc MenuOptionFunc, onSelectFunc OnSelectFunc) (*EntryNavItem, error) {
tree, err := NewFileTree(rootDir)
if err != nil {
log.Fatal(err)
}

//tree.Print()

if err != nil {
log.Println("load file tree failed", err)
return nil
return nil, err
}

return &EntryNavItem{
Expand All @@ -108,7 +100,7 @@ func NewEntryNavItem(rootDir string, menuOptionFunc MenuOptionFunc, onSelectFunc
menuOptionFunc: menuOptionFunc,
onSelectFunc: onSelectFunc,
expaned: true,
}
}, nil

}

Expand Down

0 comments on commit 92cc484

Please sign in to comment.