0

I'm trying to write a gui, as it will be drawn by skia or cairo, I know that they are used to draw GUI elements only and have nothing to do with receiving events, so I will use another library for that. I wanted to know:

How to detect whether the mouse cursor has become inside the widget, such as the rounded rectangle button, the normal rectangular button, the ellipse, the circle, and a graph under a curve...etc?

I know about some possible algorithms such as determining the widget's coordinates and determining its area, mathematically, or using the widget's color so that the event is triggered when the mouse pointer is on the widget's color, but I think the actual method used in common GUIs is different from that.

Where is the mouse pointer event listener placed? Does each widget have its own event listener, or is it associated with the parent of each widget, or is there only one event listener responsible for receiving any event when a widget interacts with the mouse pointer?

I searched on the net, but didn't find much detail on the subject.

  • I feel like this is a software design question and thus depends on design requirements and taste. You mention two options and either one works (assuming each widget has a unique color, which I find a bit odd, but okay, if it works for you). – Uli Schlachter Aug 18 '23 at 18:28
  • I'm trying to write a simple gui programmatically, let's say through c++ or rust , but I need to know all possible algorithms and methods related to the topic – Fangamesgamer Aug 18 '23 at 20:19

0 Answers0