pointerdown not working on text
See original GitHub issueThe alert below never gets called, I have tried registering the pointer event using both the text object and its bounds.
<html>
<head>
<title>MelonJS Text pointerdown not working</title>
<script src="https://cdn.jsdelivr.net/npm/melonjs@7.1.1/dist/melonjs.js"></script>
<script>
let menu=me.Stage.extend({
init:function(){
this._super(me.Stage,'init');
},
onResetEvent:function(){
this.text=new me.Text(me.game.viewport.getWidth()/2,me.game.viewport.getHeight()/2,{
font:'sans-serif',
size:72,
text:'test',
anchorPoint:new me.Vector2d(0.5,0.5),
fillStyle:'#ffffff',
strokeStyle:'#ffffff'
});
me.input.registerPointerEvent('pointerdown',this.text,function(){alert('pointerdown')});
me.input.registerPointerEvent('pointerdown',this.text.getBounds(),function(){alert('pointerdown')});
me.game.world.addChild(this.text);
}
});
me.device.onReady(function(){
me.video.init(document.body.clientWidth,document.body.clientHeight,{
wrapper:'screen',
scale:'auto',
scaleMethod:'flex'
});
me.loader.preload([],function(){
me.state.set(me.state.MENU,new menu());
me.state.change(me.state.MENU);
});
});
</script>
<style>
#screen{
position:absolute;
left:0;
top:0;
width:100%;
height:100%;
}
</style>
</head>
<body>
<div id="screen"></div>
</div>
</body>
</html>
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Mousedown, pointerdown events not working when keep ...
pointerdown / mousedown events do not fire continuously while the button is held. So, you'll need detect two events: when button was pressed ......
Read more >Pointer events - Web APIs | MDN
Note: Pointer events are not available in Web Workers. Pointer events are DOM events that are fired for a pointing device.
Read more >Prevented default in onPointerDown does not trigger ... - GitHub
Hmm, I'll take a look at this today. It looks like using mousedown instead of pointerdown is also causing some issues with newer...
Read more >How does the .on('pointerdown') listener work? [Possible Bug]
The problem is that after the first press, if you do not move your cursor out of the sprite, you have to click...
Read more >Pointer events - The Modern JavaScript Tutorial
Pointer events are a modern way to handle input from a variety of pointing devices, such as a mouse, a pen/stylus, a touchscreen,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yup! Text click working. Thanks for attending to my queries!
sure, good idea ! so it’s working ?
by the way I’m still working on your example, I’m in the process of rewriting some of the canvas resizing related function of melonJS to be more robust, testing and using your example along to debug it 😃