Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Is it possible to trigger onclick event without button component?

ANSWERED

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.

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

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"/>

```

View best answer in original post

Best Answer
0 Votes
2 REPLIES 2

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"/>

```

Best Answer
0 Votes

Thanks a lot! It works!

Best Answer
0 Votes