ptotoUI and onItemClick

Hello! I tried to create my own view with mouse event handling.

webix.protoUI({
	name: "mapStatusLine",
	defaults: {
		template: "…",	
		on: {
			'onItemClick': function () { }
		}
	},
	// custom stuff
}, webix.ui.template, webix.MouseEvents);

And the ‘onItemClick’ fires never. Why so? What am I doing wrong?

Hello,

You need to specify a click target as a CSS class of the needed HTML element. You can do it within the on_click property of the custom widget:

name:"mapStatusLine",
on_click:{
    "webix_template":function(e){
         this.callEvent("onItemClick", [e]);
     }
}

https://snippet.webix.com/lxz69jnq

you should not define event handlers in defaults block.
as it will not work if you add any handler in view config.
https://snippet.webix.com/90gi6b2e
instead you should add required event handler in $init.

{
   $init: function(config) {
      this.attachEvent("onItemClick", function(){
         ...
      });
   }
}