Resize Stack only once

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
hrcap
Posts: 131
Joined: Mon Jan 14, 2019 5:20 pm

Resize Stack only once

Post by hrcap » Wed Feb 23, 2022 1:45 pm

Hi Everybody

I hope that you are all well.

I have a card with a lot of objects on, as such when I drag resize the repositioning of the objects is very stuttery.

Is there a way to only reposition the objects once the resize is complete, something like:

Code: Select all


on resizestack

if mousedown = "false" then
      set_locs
end if

end resizestack


*set_locs is the command that repositions the objects.




Many Thanks

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

Re: Resize Stack only once

Post by dunbarx » Wed Feb 23, 2022 2:53 pm

Hi.

A stack with hundreds of controls can be resized by hand without issue. Do you mean that the controls themselves are to be resized along with the stack? Or do you mean thousands of controls? There is a sort of "stuttery" delay if that number live on a card.

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9287
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Resize Stack only once

Post by richmond62 » Wed Feb 23, 2022 3:03 pm

I would assume the OP's
once the resize is complete
is a way to avoid the
very stuttery
perhaps s/he needs to check out lockScreen.

Whether the OP wants only repositioning,

or repositioning and proportional resizing is unclear.

SparkOut
Posts: 2839
Joined: Sun Sep 23, 2007 4:58 pm

Re: Resize Stack only once

Post by SparkOut » Wed Feb 23, 2022 3:23 pm

There's a couple of possible things but you could try something like this

Code: Select all

on resizestack 
   if mousedown = "false" and "set_locs" is not in the pendingMessages then 
      send "set_locs" to me in 300 milliseconds 
      -- or this card/this stack/whatever appropriate target
      -- or in suitable time delay
    end if
end resizestack
if you want to do proper triggering only to fire once for certain, however long the resize takes, you could deliberately cancel any "set_loc" message in the pendingMessages before sending a new message.

hrcap
Posts: 131
Joined: Mon Jan 14, 2019 5:20 pm

Re: Resize Stack only once

Post by hrcap » Wed Feb 23, 2022 3:52 pm

Perfect thanks chaps

The main problem with the stuttering is because there is a datagrid on the layout which adjusts the height of each of its rows depending on its contents.

I gave the lock screen a go but couldn't get this to work.

I am successfully using:

Code: Select all


   if "set_locs" is not in the pendingMessages then 
      send set_locs to me in "300" milliseconds
   end if


Many Thanks

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Resize Stack only once

Post by Klaus » Wed Feb 23, 2022 3:59 pm

Some hints:
We do not need to use "lock screen" in resizestack handler:
The screen is locked while a resizeStack handler is running, so it is not necessary to use the lock screen command to prevent changes from being seen. (However, the lockScreen property is not set to true.)
And MOUSEDOWN is a message and not a function, means it will always return FALSE, if the mouse is down or not.

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

Re: Resize Stack only once

Post by dunbarx » Wed Feb 23, 2022 4:40 pm

I think what Sparkout meant was "if the mouse is up".

The way is was written was as if "mouseDown" was a variable, and contained the string "false'. In fact LC allows this:

Code: Select all

put "false" into mouseDown
but it is likely, um, not very good practice. Anyway, that is why no error was thrown...

Craig

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Resize Stack only once

Post by Klaus » Wed Feb 23, 2022 6:02 pm

Just saying, Craig. :-)

SparkOut
Posts: 2839
Joined: Sun Sep 23, 2007 4:58 pm

Re: Resize Stack only once

Post by SparkOut » Wed Feb 23, 2022 6:17 pm

Yes I am working on phone and just copied the op script. I meant

Code: Select all

if the mouse is not down and...
And when using "send" then always quote the message to be sent.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”