Skip to content

How to detect mouse input on Painter shapes and lines? #4861

Closed Answered by YgorSouza
Swarkin asked this question in Q&A
Discussion options

You must be logged in to vote

The painter doesn't interact with user input, it just paints. You can only detect user input inside a rectangle, using something like Ui::allocate_response or Ui::allocate_painter. You can also get the pointer position with Ui::input and then write your own logic to determine what it is hovering. The shapes themselves don't have a way to determine whether they contain a given point. They only offer a visual_bounding_rect to get the rectangle containing the shape. That is why when you click the circular widgets like radio buttons, you can click on the corners outside the circle. All hitboxes are actually rectangles.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by Swarkin
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants