I’m looking to create a Space-Lua command for generating study notes. Is it possible to have a filter box that includes the option to create a new module attribute, similar to how the page picker allows creating new pages? For example, if I select “Java” as a new module, the function should return “Java”. Here’s my example code:
function test()
return editor.filterBox("Module", {{name="Math"},{name="Cpp"}, {name="German"}, {name="AI"}}, "For which module are the notes?")
end
If you only want to have your function to return just “Java”, (where it currently returns a table), you simply could add “.name” at the end after the last “)”, like this:
```space-lua
function pagepicker_test()
return editor.filterBox("Module", {{name="Math"},{name="Cpp"}, {name="German"}, {name="AI"}}, "For which module are the notes?").name
end
```
No, in the Example is Java not in the choices. I search a possibility to add a new choice. My workaround at the moment is, that the last choice is new and than I open a prompt to type in the new module. So something like the create new page function of the page picker.
You can press Shift+Enter after typing a new option in the filter box and it will return an object that looks like { name = "your value" }. Same as with the page picker (Ctrl+k).