# Touch event on graphics

**URL:** <https://phaser.discourse.group/t/touch-event-on-graphics/9864>\
**Category:** Phaser 3\
**Created:** [June 29, 2021, 1:20pm UTC](https://phaser.discourse.group/t/touch-event-on-graphics/9864 "2021-06-29T13:20:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![atreibout](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@atreibout](https://phaser.discourse.group/u/atreibout)\
**Post date:** [June 29, 2021, 1:20pm UTC](https://phaser.discourse.group/t/touch-event-on-graphics/9864/1 "2021-06-29T13:20:32Z")

</div>

Hi everybody 🙂

I want to do this :

```javascript
var graphics = this.add.graphics();
        graphics.fillGradientStyle(0xffff00, 0xffff00, 0xff0000, 0xff0000, 1);
        graphics.fillRect(0, 700, game.config.width, 400);
        graphics.setInteractive().on('pointerdown', function(pointer, localX, localY, event){
            alert('e');
        });

```

But even if i touch with the cursor my rectangle, prrrrrrrt, he doesn’t care…

 ![image](https://global.discourse-cdn.com/free1/uploads/phaser1/original/2X/3/39b6d321c3fe6e43afa6692747131c1cf1d657dd.jpeg)

what i miss please ?

thx guys !

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [June 29, 2021, 2:48pm UTC](https://phaser.discourse.group/t/touch-event-on-graphics/9864/2 "2021-06-29T14:48:30Z")

</div>

Graphics has no size, so no implicit hit area. You must pass a hit area and test function. See examples in [Phaser.GameObjects.GameObject#setInteractive](https://newdocs.phaser.io/docs/3.55.2/Phaser.GameObjects.GameObject#setInteractive).

---

<div class="post-metadata">

**Author:** ![atreibout](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@atreibout](https://phaser.discourse.group/u/atreibout)\
**Post date:** [June 29, 2021, 3:01pm UTC](https://phaser.discourse.group/t/touch-event-on-graphics/9864/3 "2021-06-29T15:01:45Z")

</div>

thx for the reply 🙂  
ok, i’ll see how to do that !
