JSON UI Woes
-
Thanks Christoph. I've pushed it to github and added in the framework as a submodule as you suggested. I haven't relinked all of the external scripts yet though, just the playable range and mic mixer. The front interface script is not an external file, it has a few includes to my framework and I've updated these links.
-
I've took a quick look at the current state. The interface is not empty, it is just masked by the grey panel for the top bar (it has a height of 290).
There's also a few other fishy things like the id
aeLeftLabel
andaeleftLabel
, which I suppose should be the same thing.I found the best workflow to migrate to the new Interface designer approach to click on all properties that are overwritten by the script and comment out that line (don't worry, the properties are persistent), then you can use the Interface Designer to clean up.
-
Thanks for taking a look. I'll tinker around with it and hopefully make some progress
-
I don't think this commenting out tactic is going to work. A lot of the places it's saying the code is overwriting are in my factory functions so it takes me to lines like this
local control = Content.addPanel(id, x, y);
If I comment that out then it's going to cause some other issues.I've fixed the issue with aeLeft now.
I've also tried creating a new preset, adding a script processor, and connecting it to my mic mixer module, the interface is blank and the UI JSON and component list are empty. My key range module though doesn't seem to have any problems and the interface shows up.
-
Yes that is true, because the widget definition overwrites the position with the
x
andy
parameters. The solution is pretty simple. In your factory function, replace:local control = Content.addPanel(id, x, y);
with
local control = Content.getComponent(id);
in order to not overwrite the position in the factory method, but still get a reference that you can use to set up the widget. I did this last week with an older project that I am migrating to support the Interface designer. I've even added a context menu tool that converts these lines for you automatically (select the whole line and then right click -> Convert addWidget to Content.getComponent().
With this approach, you need to create the widget first (either in the interface designer or using the Content.addXXX methods before you call the factory function. Think of it that now the factory functions just shape the already existing widget into the thing you want.
-
That seems like a good solution, thanks. I'll give it a go
-
Ok I've reworked my uiFactory so it's more of a property setter and changed the way my controls are declared.
When I go the property inspector I'm still getting the
This property was overwritten by the script
message. I click show on the first one - the x position of my keyboard floating tile - and it takes me to this lineconst var keyboard = Content.addFloatingTile("keyboard", 0, 300);
Commenting out this line won't solve it so I'm not sure what to do...Update: I've got my GUI back partly - I'm making progress :)
-
Well you don‘t need that line after all. As soon as you created the widget either by calling that line once or more conveniently by just adding a widget in the unterface designer, you can safely delete it because the created component is persistent.
-
I'm so confused :-( so if I delete that line how do I refer to the keyboard variable elsewhere in my script? (actually I don't really need to refer to that particular component but others I do).
-
Content.getComponent("keyboard");
-
So I create the control using
Content.addControl
then I compile, then I delete that line, then I useContent.getComponent()
to get the control in a variable again? It seems to me like Content.addControl is redundantWhat I'm attempting now is to rebuild the GUI in the JSON view and not use any
Content.addControl()
commands. This isn't too bad but I have two issues, every time I hit F5 in the JSON view and it compiles it takes me back to the on init so I have to click the drop down menu again to go back to the JSON. The other issue is hex numbers don't seem to be recognised in the JSON view. -
Well I wouldn't say it's redundant, it's just not compatible with the new Interface Designer because it overwrites the position that now can't be controlled directly via mouse / key shortcuts which is like the biggest workflow enhancement of the Interface Designer IMHO.
If you choose to not bother about it and create everything with a script, you can still use the
Content.addStuff
methods, but again, you miss many things.I agree that your approach of calling the functions once, then replace it with Content.getComponent() is not very efficient. However if you start the interface from scratch you don't ever need to call one of these functions because you can create and rename the widgets directly via context menu in the interface designer (either by right clicking on the canvas or on one of the items in the widget list). So basically the recommended workflow now is:
-
Create all widgets using the interface designer, shuffle them around and set its properties, connect it to modules etc. without having to touch the script editor once.
-
As soon as you want to implement custom behaviour, customise a Panel or implement some complicated GUI logic, grab a reference to the widget (this can also be done by selecting it and pressing Ctrl+C, it will copy the line
Content.getComponent(name)
to the clipboard) and use this to add the code you need.
If you take a step back, this procedure is starting to become similar to the way how you connect modules with a script (just grab a reference and do something with it instead of create it completely from scratch).
-
-
I've been trying to rebuild the UI from scratch, I find the ui designer really slow compared to working in the script (especially with multiple cursors) though so I've been creating controls in the JSON view, however like I said when I hit F5 it takes me to the on init so that becomes quite cumbersome too. I also just had a problem with a bunch of controls I'd created in the JSON randomly disappearing along with the JSON code... Should I not hit F5 in the JSON view but go to the normal script to compile or should I do it in both views?
Also, when using the interface designer, is it still possible to split a UI into multiple files and combine them all in the front interface script?