As you can see, there is a slider with two circular buttons and if you click one of them, it is supposed to alert ‘Bingo!!!’ but the event handler not being fired (in ui-default.js). - only event handlers attached to this.app.mouse works.
Of course, I put useInput: true like this:
// top slider
var uiTopSlider = new pc.Entity(‘ui-top-slider’);
uiTopSlider.addComponent(‘element’, {
type: pc.ELEMENTTYPE_IMAGE, useInput: true,
anchor: new pc.Vec4(0.5,1,0.5,1),
pivot: new pc.Vec2(0.5,1),
width: 64,
height: 64,
margin: new pc.Vec4(-32,-64,-32,0),
rect: new pc.Vec4(0,0,1,1),
texture: pc.app.assets.find(assetUrls[1].replace(/^.*[\/]/, ‘’)).resource
});
I can’t believe that this simple version also does not work. onMouseDown is never called.
Please take a look at ui-default.js:
// initialize code called once per entity
Button.prototype.initialize = function() {
this.sliding = false;
this.lastY = 0;
When you create the pc.Application you are not passing any options. Try this instead:
pc.app = new pc.Application(canvas, {
elementInput: new pc.ElementInput(canvas),
mouse: new pc.Mouse(canvas),
touch: !!('ontouchstart' in window) ? new pc.TouchDevice(canvas) : null,
keyboard: new pc.Keyboard(window)
});