ResizeStack oddities

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9655
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

ResizeStack oddities

Post by dunbarx » Wed Feb 02, 2022 5:27 pm

This post is based on another thread:
viewtopic.php?f=8&t=36710


The "resizeStack" message, as per the dictionary:
The resizeStack message is sent after the resizing is finished. This means that you cannot prevent a stack's size from being changed by trapping this message.
In the stack script of a card:

Code: Select all

on resizeStack
   breakpoint
   put random(99) 
end resizeStack
Nothing happens during the resize process. The breakpoint never catches anything. BUT, if one continually resizes for a little while, when the mouse is finally released, it can be seen in the message box literally dozens, if not more, random numbers being displayed in a stream. So the resizeStack message is sent repeatedly, but cannot be trapped at all. In that sense, the last part of the dictionary entry above is correct.

I think this is in fact better behavior than the dictionary states. That message ought to be sent continuously, similar to how the "mouseMove" message is sent. And it IS sent continuously, but one cannot see it at all, only getting proof at the very end.

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9655
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: ResizeStack oddities

Post by dunbarx » Wed Feb 02, 2022 5:34 pm

Added a field to the card. Had the message watcher running while resizing. A stream of "resizeStack" messages are indeed sent. In the stack script:

Code: Select all

on resizeStack
   breakpoint
   add 1 to fld 1
   put random(99)
end resizeStack
The field is constantly incremented during resizing. The message box is inundated after the resize finishes. The breakpoint never fires.

Craig

andresdt
Posts: 146
Joined: Fri Aug 16, 2019 7:51 pm

Re: ResizeStack oddities

Post by andresdt » Wed Feb 02, 2022 7:56 pm

:idea: :idea: mm reading the thread where this came from and reading the posts in this thread.
I have an idea how what Trevor DeVore proposed can be "implemented" at https://quality.livecode.com/show_bug.cgi?id=7310

PS: It's in from the LiveCode Script and not in the engine as Trevor suggests.

Code: Select all

local sResizeStackStart

on resizeStack pNewWidth, pNewHeight, pOldWidth, pOldHeight
   if not sResizeStackStart then
      dispatch "resizeStackStart" with  pNewWidth, pNewHeight, pOldWidth, pOldHeight
      put pNewWidth into sOldWidth
      put pNewHeight into sOldHeight
      put true into sResizeStackStart
   end if

   send "__resizeStackEnd pNewWidth, pNewHeight, pOldWidth, pOldHeight" to me in 0.5 sec
   pass resizeStack
end resizeStack


on __resizeStackEnd pNewWidth, pNewHeight, pOldWidth, pOldHeight
   if lineOffset("__resizeStackEnd",pendingMessages()) <> 0 then exit __resizeStackEnd
   put false into sResizeStackStart
   dispatch "resizeStackEnd" with pNewWidth, pNewHeight, pOldWidth, pOldHeight
end __resizeStackEnd 


on resizeStackStart  pNewWidth, pNewHeight, pOldWidth, pOldHeight
   set the backcolor of me to any line of the colorNames
end resizeStackStart

on resizeStackEnd  pNewWidth, pNewHeight, pOldWidth, pOldHeight
   updateUI
end resizeStackEnd

command updateUI
   put the millisec, "resizeStackEnd"
   set the rect of fld 1 to the rect of this cd
end updateUI

Post Reply

Return to “Talking LiveCode”