Skip to content

simulation-tree/file-dialog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 

Repository files navigation

File Dialog

Implements NativeFileDialogSharp asynchronously.

Features

  • Open multiple files
  • Open and save single files
  • CHoose directories

Usage

Using this library is done by creating temporary FileDialogEntity entities:

using World = new();
using Simulation simulator = new();
using Text selectedPath = new();
simulator.AddSystem<FileDialogSystem>();

FileDialogEntity.OpenFile(world, new(&ChosenFile), userData: selectedPath.Address);

while (selectedPath.Length == 0)
{
    simulator.Update();
}

Console.WriteLine(selectedPath);

[UnmanagedCallersOnly]
static void ChosenFile(Chosen.Input input)
{
    Text selectedPath = new((nint)input.userData);
    if (input.status == FileDialogEntity.Status.Cancelled)
    {
        selectedPath.CopyFrom("Cancelled");
    }
    else
    {
        selectedPath.CopyFrom(input.Paths[0]);
    }
}

The function pointer can be reused for other operations, with the input.type value allowing for differentiating between each. As well as input.status allowing to check if the operation was cancelled, failed, or completed successfully.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages