Send the Stack to the Center of the screen.

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

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

Re: Send the Stack to the Center of the screen.

Post by richmond62 » Sun Dec 17, 2023 11:12 am

This is a big pain-in-the-bum:
-
KBx.jpg
-
But with some sort of scaling being able to happen things could get considerably better:
-
KBy.jpg
-
keyBoardActivated being made available on LC Desktop would be a great boon.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4003
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Send the Stack to the Center of the screen.

Post by bn » Sun Dec 17, 2023 9:50 pm

Here is a stack that simplifies setting the loc of a scaled stack. I has a handler 'setLocation' that is generic enough to be used in other projects (button 'setLoc')

After Stam's very useful explanation and sample stack at the beginning of this topic I figured that a simple way to handle moving scaled stacks would be useful.

It boils down to this

Code: Select all

put "number", "number" into tTargetLoc
put the scaleFactor of stack "myStack" into tScale
put item 1 of targetLoc / tScale into item 1 of tTargetLoc
put item 2 of targetLoc / tScale into item 2 of tTargetLoc
set the topLeft of stack "myStack" to tTargetLoc
That is it and it works.

I added the case that you want to move a scaled paletted stack. I turns out that LC apparently thinks for the top that the title bar of a stack is always the title bar of a topLevel stack which does not quite work for paletted stacks (or I did not find out how).
I resorted to a stunt that creates an invisibe stack on the fly and calculates the difference of the height of the title bar between a toplevel version and a paletted version and added that difference to the coordinates.

Kind regards
Bernd
Attachments
settingLocOfScaledStack.livecode.zip
(2.26 KiB) Downloaded 42 times

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

Re: Send the Stack to the Center of the screen.

Post by richmond62 » Wed Mar 27, 2024 10:44 am

I'm a little puzzled by the slippage of your revMenuBar though
Whose revMenuBar would you be referring to? Your comment is a bit decontextualised.

----------

Oh, and as this is you first postage, welcome to these forums.

How long have you been working with LiveCode?

Post Reply

Return to “Talking LiveCode”