Hi. I have a widget named DrawingWidget. It contains another widget call Paper. I want to draw lines inside the paper widget and ONLY ON the paper widget (since its smaller that its container).
I have already figured out how to draw lines correctly. Now I want to figure out how to limit the drawing functionality to inside the Paper widget. I have been stuck on this for 2 days, here’s what I have already tried:
- Standard events: MouseEnter, Leave. Problem: They are not called when any mouse buttons are pressed down, so I can simply draw outside the widget.
- Touch events with mouse touch enabled. I encountered the same problem.
- Get geometry of widget, compare mouse position to see if mouse is in widget. Problem: Widget geometry doesn’t equal to area of widget.
- Build array of all pixels that are part of widget using geometry, then get mouse position and call contains() on the widget. I encountered the same problem.
Please, if you have any alternative ideas, I am open! I probably also left out some things I tried but I covered most of it.