macOS Mojave Version: 10.14.2
Xojo 2018 Release 4
I have an app that is "older" in the sense that I have been working on and off on it for a couple years. So it has seen various versions of Xojo.
I have recently been re-jiggering canvases to embrace Group2D and Object2D.
I have code to clear the canvas. When I run that code I am expecting the canvas just to clear. But instead it becomes solid black.
Trying to understand this happening, I wrote a simple sample app with a single canvas. In the sample app, I use the same code. When I clear the canvas, it does what I expect: the canvas clears.
So I disassembled my original app, discarding all the pieces slowly trying to find out what was "different". Finally, the original app was reduced to just a single window with a single canvas. But the behavior persisted. Running code to clear the canvas results in a solid black canvas.
Here is the code present in both applications. All the action takes place in the paint event of the canvas (cnLook)
cnLook: paint event
If Self.bClear Then g.ClearRect(0, 0, g.Width, g.Height) Self.bClear = False End If If Self.bSquare Then // g.DrawObject(Self.someShape, 100, 100) Dim r As New RectShape r.Width = 75 r.Height = 75 r.Border = 100 r.BorderColor = RGB(0, 0, 0) // black r.FillColor = RGB(0, 127, 127) // teal r.BorderWidth = 2.5 g.DrawObject(r, 100, 100) Self.bSquare = False End If
The window has two properties (Booleans)
The window has two buttons with the Action code below.
Self.bClear = True Self.cnLook.Invalidate
Self.bSquare = True Self.cnLook.Invalidate
Canvas Setting are the default in both:
Visible, AutoDeactivate, Enabled, UseFocusRing All ON
Accept Focus, AcceptTabs, Double Buffer: All these OFF
The logic of all this is fairly straight forward. The user clicks on one or the other of the buttons. The window property bSquare or bClear get set to True and the invalidation of the canvas forces the Paint event to fire. The line of code below, is intended to clear the canvas but behaves differently in the two apps.
g.ClearRect(0, 0, g.Width, g.Height)
When pbClear is clicked in one application the canvas turns black. In the other application it is cleared.
When pbDrawSquare is clicked, both applications behave identically. A square is drawn on a clear background.
I am confounded by this. I am asking to see if anyone has seen something like this or knows how to "correct" my old app so this behavior does not occur.