04-07-2019 10:06 - edited 04-07-2019 10:07
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

04-07-2019 10:06 - edited 04-07-2019 10:07
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Is it possible to trigger onclick event without button component? I want to trigger onclick event when user press custom element (circle, text).
For example
//index.gui
<circle id="btn" cx="75" cy="230" r="50" fill="red" />
//index.js
const btn = document.getElementById("btn");
btn.addEventListener("click", () => {
console.log('XXXXXXXXXXXXX');
});
Everything works when I use button components, but I need clickable custom images or text without borders what button components have.
Answered! Go to the Best Answer.
Accepted Solutions
04-07-2019 10:21 - edited 04-07-2019 10:23
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

04-07-2019 10:21 - edited 04-07-2019 10:23
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I think if you add `pointer-events="visible"` to the circle component, it should respond to click/touch events
i.e.
```
<circle id="btn" cx="75" cy="230" r="50" fill="red" pointer-events="visible"/>
```

04-07-2019 10:21 - edited 04-07-2019 10:23
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

04-07-2019 10:21 - edited 04-07-2019 10:23
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I think if you add `pointer-events="visible"` to the circle component, it should respond to click/touch events
i.e.
```
<circle id="btn" cx="75" cy="230" r="50" fill="red" pointer-events="visible"/>
```

04-07-2019 10:39
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

04-07-2019 10:39
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Thanks a lot! It works!

