I'm developing an addon that opens a settings window where I can configurate things like the background color of another window that will be open later.
The settings window has a button that opens a modal window (called dlgColorPicker) that has a color picker tool, a OK button and a Cancel button so I can choose a color and click OK.
Code: Select all
<head>
<title>Dance Floor Display</title>
<script src="file:///mminit.js"></script>
<script src="dlgColorPicker.js"></script>
<script src="file:///controls/button.js"></script>
<script src="file:///controls/colorPicker.js"></script>
</head>
<body data-posSaveName='dlgColorPicker' data-defaultSize='400,400'>
<div id="id_colorPicker" data-control-class="ColorPicker" data-id="colorPicker"></div>
<section style="height: 30%; color: red; text-align: center; background-color: green">
<div data-control-class="Buttons">
<div data-id="btnOK">OK</div>
<div data-id="btnCancel">Cancel</div>
</div>
</section>
</body>
</html>
Code: Select all
UI = null;
gl_this = this;
var gl_mainWindow = app.dialogs.getMainWindow();
function init(params) {
UI = getAllUIElements();
}
app.listen(qid('btnOK'), 'click', event_OK);
async function event_OK(event) {
console.log('Color accepted');
gl_mainWindow._window.gl_backgroundColor = UI.colorPicker.controlClass.value;
gl_mainWindow._window.myEvent_changeBackgroundColor = createNewCustomEvent('changeBackgroundColor', {
detail: {
newBackgroundColor: UI.colorPicker.controlClass.value
}
});
gl_mainWindow._window.dispatchEvent(gl_mainWindow._window.myEvent_changeBackgroundColor)
console.log('OK')
gl_this.close();
}
I guess I shouldn't close the window using the "gl_this.close()" line but I don't know another way.
Thanks,
Marcelo