MacOSX does not accept Canvas Output outside OnPaint Message lazarus / 39-Graphics ---------------------------------------------------------------------- Martin V · 2010-06-23 12:22 Hello, in Win32 and gtk2 (Linux), you can simply draw something e.g. to the Form.Canvas in an arbitrary event like OnClick: Code: [Select]procedure tForm1.Button1OnClick;   begin      Canvas.MoveTo (1,1);      Canvas.LineTo (100,100);   end; In MacOSX, there's no output shown and the only way to get Canvas output is to do it in the OnPaint message. This is a really big difference to the other OS. Is it a Lazarus bug or a system-specific limitation? How can I modify my application (an editor) which often writes to the Canvas forced by the user and not in a PAINT message procedure? I made a dirty workaround by executing Form.Invalidate after every Canvas Output. Invalidate generates a PAINT message. But in this case, the whole window gets repainted. Martin ---------------------------------------------------------------------- theo · 2010-06-23 12:56 Yes, that's the correct way imho for all widgetsets. Invalidate -> Paint. You can also invalidate only parts using InvalidateRect (LCLIntf) and Canvas.ClipRect in overridden procedure Paint. ---------------------------------------------------------------------- zeljko · 2012-07-04 05:24 You are drawing outside of paint event and that's why it does not work. Same thing is with qt widgetsets on any platform. To get it work you must do paint stuff in Form.OnPaint() , and in ButtonClick just call Update; MacOSX (carbon and cocoa) and Qt does not support painting outside of paint event. ---------------------------------------------------------------------- felipemdc · 2012-07-04 05:41 Quote from: Martin V on June 23, 2010, 02:22:57 pmIn MacOSX, there's no output shown and the only way to get Canvas output is to do it in the OnPaint message. This is a really big difference to the other OS. Is it a Lazarus bug or a system-specific limitation? How can I modify my application (an editor) which often writes to the Canvas forced by the user and not in a PAINT message procedure? I made a dirty workaround by executing Form.Invalidate after every Canvas Output. Invalidate generates a PAINT message. But in this case, the whole window gets repainted. In general most platforms do not support painting outside the paint event, examples: Carbon, Cocoa, Qt, LCL-CustomDrawn (in all platforms, including Android). If you want to make a continuous draw, then store it in a TBitmap and call .Invalidate or InvalidateRect (I would avoid messing with the clip rects, InvalidateRect should be all you need). Invalidate is not a workaround, it is the proper cross-platform solution. Your OnPaint event would then draw this stored bitmap to the canvas.