Hi,
I’m trying to emulate the splitter behavior of Apple Mail, but I’m having trouble getting to work smoothly. Please see my test project here.
I need to resize the canvas so that it’s backdrop is filled in, but the way I’m doing it is slow to fill. Also, when resizing the window, the splitter won’t move the listbox above it properly.
I’m using imSplitter which I believe was contributed by forum member @Oliver Osswald Thank you, Oliver.
Well, this confuses me because I read on the forum that when a canvas is used a container, nothing should be placed in Paint event. Drawing a white background in the Paint event could cause flickering. I think this was recommended by @Michel Bujardet For that reason, I went with a backdrop.
On the Mac you have to do a lot to cause flickering. Haven’t seen ever problems with paint events of canvases in a container and I use these everywhere. On the dark side things are different. For which platform do you develop?
Use the paint event
OS X is inherently double buffered and you REALLY have to work hard to make it flicker
Drawing in the paint event and calling invalidate or refresh IN the paint event is likely to do it
It’s already been written and it’s in the test project I posted, but it’s acting wonky. I thought maybe someone could take a look and point me in the right direction.
Jeff, thanks for your help. However, most of this has already been done. Norman commented on moving the redraw of the canvas into the Paint event. Sorry I should have updated the test project. Thanks for spotting the recursive lines though!
The problem I’m having difficulty with is that when the splitter is dragged all the way to the bottom of the window.
If the user first resizes the window larger. Then drags the splitter all the way to the bottom of the window. Then resizes the window back up, the splitter doesn’t stay docked at the bottom of the window. You have to expand the window again to find it. Apple Mail does it correctly.
So dont you just need code to check the splitter top relative to the height of the window.
In the resizing / resized event of the window, move the splitter if it is too far down.
[quote=245182:@Michel Bujardet]
Michel Bujardet 20 hours ago Beta Testers, Xojo Pro @Mark Scardingo Well, this confuses me because I read on the forum that when a canvas is used a container, nothing should be placed in Paint event. Drawing a white background in the Paint event could cause flickering. I think this was recommended by @Michel Bujardet For that reason, I went with a backdrop.
On Mac you will be fine with Paint.[/quote]
There can be some situations where the paint event is a bit too slow, like when loading a not-yet-initialized NSImage to draw it in the paint event, and turning on double buffering may lead to a white background instead of a transparent one.
In that cases, I have found flicker is removed when you make the underlying NSView have a layer with a Wantslayer = true call by declare.