I’m struggling to get a simple button to work. Since I need to send commands at mousedown and mouseup events I thought why not make my own. My web development skills are limited, but I assume it is just some simple mistakes in the html/css.
So I managed to get basic functionality to work even with js and a controller in the background. However, click events only work on the backdrop icon or a paragraph. How would I change the html to send click events clicking anywhere on the widget.
Secondly, setting the background color is a mess. If I hard code it, it only appears behind the text and if I try to connect it to a javascript variable it doesn’t do anything at all
Ok, after lots of try and error I finally figured it out myself.
The div on the lazy-load shrunk the size/area, this had effect on both the event and the background problem.
Following a working example, make sure you have all config set up: name [string], background_active [color], background_inactive [color], foreground [color], backdrop_icon [icon], backdrop_center [checkbox], item [item].
The javascript file needs to be placed in /etc/openhab2/html/touchbutton-widget/touchbutton_ctrl.js, then in Habpanel edit a dashboard and instead of inserting a widget click on custom widgets and create a new one. Copy paste the html and setup all config variables. You should now have a small working example of a custom widget with an angularjs controller.