On 10/28/12 01:53, Klaus Rudolph wrote: > I want to create some simple non rectangle widgets. > > It is quite simple to derive from any widget class, but all the classes > have a rectangle boundary. Any mouse event will be handled to the > rectangle region of the box of the widget I derive from. > > What can I do to only get / filter the incoming mouse events to my e.g. > circular region?
Create your widget so that the circle is within the xwyh rectangular boundary. Then make your own function called e.g. event_inside_circle(x,y) which, given an x,y value, returns true if the x,y value is inside the circle, and false if not. Use this in your widget's handle() method to accept/reject events like FL_PUSH/FL_RELEASE, and detect mouse movement over the circular region for events like FL_MOVE (e.g. if you want it to 'light up' when the mouse is over it) Use Fl::event_x(),Fl::event_y() to get the x,y position of the event. If you need FL_MOVE events, be sure to return 1 in response to FL_ENTER or you won't get them. Be sure to still process other events like FL_ENTER normally, as fltk will be expecting responses to these, and will only issue them at your rectangular border. It becomes up to your widget to handle non-rectangular boundaries within that region for subsequent event handling like FL_MOVE, FL_PUSH, FL_RELEASE.. _______________________________________________ fltk mailing list fltk@easysw.com http://lists.easysw.com/mailman/listinfo/fltk