New UI Widget Support Step-By-Step
Revision as of 13:12, 20 June 2020 by Admin (talk | contribs) (Protected "New UI Widget Support Step-By-Step" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)))
Here, we’ll add support for a new UI Widget in makehaus-js and create a simple UI implementation for the same in the MakeHaus Web UI. We’ll be using “FADER
” as our example.
Before beginning, ensure to set up your environments for development as mentioned previously.
Full code is checked into both the makehaus-js and the MakeHaus Web UI repositories on a branch called “new-widget
”.
In makehaus-js:
- Add the name “
FADER
” as a new entry in theWidgetType
enum located insrc/widget/widget.ts
. Since this will be aUIWidgetType
, add the new entry, i.e.,WidgetType.FADER
to theUIWidgetTypes
constant in the same file. - To test this new widget, we’ll use the
makehaus-simple-encoder8-turn
layout json located atexamples/layouts/makehaus-simple-encoder8-turn.json
In MakeHaus Web UI:
- Create a new UI Widget Implementation. In this example, the widget we’ll use is a standard HTML input tag. The implementation can be found at
src/components/mpa-html-ui-widgets/input-fader.jsx
. Call the new UI Widget componentMpaFaderInput
. - Create a new MPA Widget Interface. Duplicate the file
src/components/mpa-widget-interface/slider.jsx
and call your new filefader.jsx
(Existing implementation can be found atsrc/components/mpa-widget-interface/fader.jsx
). - Change the name of the component to
MpaFader
. Let the other functions remain exactly the same as they were inslider.jsx
. - In the render method of
fader.jsx
, returnMpaFaderInput
. - In
src/components/mpa-widget-interface/widget.jsx
, add a new else clause with the condition set to match “FADER
”.
Now run the example located at examples/makehaus-simple-encoder8-turn.js
.