NovaOS
GithubHomeLaunchNeed help?
  • Welcome to NovaOSđź‘‹
  • Get started
    • Access NovaOS
  • How to
    • NovaOS How To
      • Setting a custom wallpaper
      • Changing default openers
      • Using default apps
        • Nova Files App
      • Data recovery
      • Using the Tasks Dock
    • Publish to Nova Store
    • Protips
    • Feedback and suggest
    • Support NovaOS
  • docs
    • Basics
      • Introduction
      • Timing
      • File system
        • Overview on files
        • File management
      • User choices
        • Settings Keys
        • Choose files
      • Managing self
        • The Open Launch Protocol
        • The EventBusWorker
    • Standards
      • Styling standards
      • Error standards
    • Networking
      • Rotur In NovaOS
    • Features
  • References
    • The NovaOS Check list
    • Methods
      • Database management
      • File management
    • NTX Actions
    • Projects
  • Epic
    • Achievements
Powered by GitBook
On this page
  • Determining the file app
  • Requesting an 'opener'
  • Opener params
  • Reciving the selected file

Was this helpful?

  1. docs
  2. Basics
  3. User choices

Choose files

PreviousSettings KeysNextManaging self

Last updated 5 months ago

Was this helpful?

This page is all about letting a user choose a file from their file system. NovaOS lets users select files from the registered app which has its capabilities including 'file'.

Determining the file app

To allow for customizability, NovaOS lets users use a files app of their choice. But which files app do we open to choose a file?

fileTypeAssociations is a system that lets apps register their supporting file types - file types they can handle.

 let appIdToOpen = window.parent.fileTypeAssociations['file'][0] || null;

Now, as we got appIdToOpen, which is the files app we can request to let the user choose a file, lets ask it.

Requesting an 'opener'

Here is the method to summon a choose file window with the default files app in NovaOS.

let appIdToOpen = window.parent.fileTypeAssociations['file'][0] || null;
window.parent.openlaunchprotocol(appIdToOpen, { 
                "opener":'any', "dir": "Downloads/" 
                }, currentreqID, myWindow.windowID);

Here, we use the to launch the application with the data, which has some params.

Apps can access this feature through the myWindow method. To use the myWindow method, you have to use the greenflag() function. Otherwise, it will return undefined. This is due to the fact that the myWindow object is only defined after the app document is loaded.

More: , .

Opener params

Opener param
description
examples

opener

A file type to filter with.

"opener":"json" "opener":"app"

dir

A directory to initialize the choose file window with.

"dir":"Downloads/" "dir":"Apps/"

Reciving the selected file

Here is a snippet that recives a file from a choose file window.

window.addEventListener('message', async (event) => {
  if (event.data.action === 'loadlocalfile') {
    if (event.data.id === myWindow.windowID) {
      console.log(event.data.returned); // this is the file ID.
    }
  }
});

OL protocol
greenflag
mywindow