I’ve a strange problem on Big Sur while using “setFrame:display:animate:” to animate the change in height of a window. It has worked for many years on any type of window. Suddenly in Big Sur often fails on sheet windows.
When I say it often fails, it works correctly the first time for a given window and then after that it changes size but it happens very fast. It doesn’t matter if the initial change is an increase in height or a decrease it always works first time and not after that. It’s almost as if the time for the animation gets greatly shortened after the first call. It works a treat for other window types, but not sheets. I’ve also half a thought that it’s because sheets are vertically centred on Big Sur, so in effect it’s not just the height that changing it’s also the top.
The Pushbutton action event as follows:
If Self.Height = 500 then ChangeHeightTo( 700 ) Else ChangeHeightTo( 500 ) End if
Sub ChangeHeightTo( nHeight as Integer ) If Self.Height <> nHeight Then #If TargetMacOS #If Target64Bit Dim newRect As NSRect64 Dim contentRect As NSRect64 Declare Sub setFrameDisplayAnimate Lib "Cocoa" selector "setFrame:display:animate:" (windowRef As Integer, rect As NSRect64, display As Boolean, animate As Boolean) Declare Function contentRectForFrameRect Lib "Cocoa" Selector "contentRectForFrameRect:" (id As Integer, windowFrame As NSRect64) As NSRect64 #Else Dim newRect As NSRect32 Dim contentRect As NSRect32 Declare Sub setFrameDisplayAnimate Lib "Cocoa" selector "setFrame:display:animate:" (windowRef As Integer, rect As NSRect32, display As Boolean, animate As Boolean) Declare Function contentRectForFrameRect Lib "Cocoa" Selector "contentRectForFrameRect:" (id As Integer, windowFrame As NSRect32) As NSRect32 #EndIf newRect.Origin.x = Self.Left newRect.Origin.y = Self.Top newrect.Dimen.width = Self.width newrect.Dimen.height = nHeight contentRect = contentRectForFrameRect(Me.Handle, newRect) newRect.Origin.y = Screen(0).Height - (newRect.Origin.Y + Me.Height) - (newRect.Dimen.Height - Me.Height) newRect.Dimen.Height = newRect.Dimen.Height - (contentRect.Dimen.Height - newRect.Dimen.Height) // adjust for the titlebar/toolbar setFrameDisplayAnimate Me.Handle, newRect, True, True #Else nNewHeight = nHeight nChange = ( nHeight - Self.Height ) / 2 StartTimer #EndIf End If