Centering stack on current monitor

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
bergsy
Posts: 45
Joined: Mon Oct 28, 2013 10:51 pm

Centering stack on current monitor

Post by bergsy » Sun Mar 15, 2015 8:38 am

Hi,

I am using the following code to toggle fullscreen. I use Ctrl-F for the toggle. I had assumed that when I toggle from fullscreen that the stack would go back to it's original position, but alas it does not. Sometime the stack is positioned so that the top part is missing and thus interaction with the stack is problematic. The workaround I have implemented just centers the stack when the user toggles out of fullscreen mode. Works great on systems with a single monitor. If my stack is showing on a second monitor, the fullscreen mode works, but toggling back and centering puts it back on the main monitor.

Is there any way I can force my stack to be positioned to the center of the second monitor?

Thanks

Bergsy

on centerMe
set the loc of this stack to the screenLoc
end centerMe

on standardPreOpen
centerMe
set the fullscreen of this stack to false
--set the fullscreenmode of this stack to "exactFit"
set the fullscreenmode of this stack to "letterbox"
end standardPreOpen

on handleCommands theKey
--if theKey is not a number then beep
if theKey = "f" or theKey = "F" then
put the fullscreen of this stack into bFullScreen
set the fullscreen of this stack to not bFullScreen
centerMe
end if
end handleCommands

on preOpenStack
standardPreOpen
end preOpenStack

on commandkeyDown theKey
handleCommands theKey
end commandkeyDown

WaltBrown
Posts: 466
Joined: Mon May 11, 2009 9:12 pm
Location: NE USA

Re: Centering stack on current monitor

Post by WaltBrown » Sun Mar 15, 2015 2:21 pm

Look at "screenRects" in the Dictionary. I've used that to determine which screen the user has put the stack.
Walt Brown
Omnis traductor traditor

bergsy
Posts: 45
Joined: Mon Oct 28, 2013 10:51 pm

Re: Centering stack on current monitor

Post by bergsy » Thu Mar 26, 2015 6:40 am

Hi,

I ended up saving top, left, width, height and loc before going to full screen, and using those saved values when I toggle out of full screen

In case anyone else needs to know

Cheers

Bergsy

zaxos
Posts: 222
Joined: Thu May 23, 2013 11:15 pm
Location: Greece

Re: Centering stack on current monitor

Post by zaxos » Thu Mar 26, 2015 1:53 pm

Code: Select all

on mouseUp -- this can be changed to handle cntrl+F
set itemDel to comma
if the width of this stack > (item 3 of the screenRect*50)/100 then
get setStack(50) -- set the stack to 50% of the screen
else
get setStack(100) -- set the stack to 100% of the screen
end if
end mouseUp

function setStack tMsg
set itemDel to comma
set the width of this stack to (item 3 of the screenRect*tMsg)/100
set the height of this stack to (item 4 of the working screenRect*tMsg)/100
set the loc of this stack to the screenLoc
end setStack
Just adding to your thoughts, with this code you can have standard widths and heights (e.x. 50% of the current screenRect).
Knowledge is meant to be shared.

WaltBrown
Posts: 466
Joined: Mon May 11, 2009 9:12 pm
Location: NE USA

Re: Centering stack on current monitor

Post by WaltBrown » Sat Mar 28, 2015 2:36 am

Here's a stack I use to find wayward stack windows in multi screen space - I sometimes park open stacks off screen. It may help.
Walt
Attachments
idShowScreen.zip
(2.88 KiB) Downloaded 240 times
Walt Brown
Omnis traductor traditor

ewanrichardson
Posts: 11
Joined: Wed Aug 03, 2016 4:24 pm

Re: Centering stack on current monitor

Post by ewanrichardson » Sat Jun 09, 2018 1:27 am

That is brilliant, thank you!

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

Re: Centering stack on current monitor

Post by andresdt » Fri Apr 09, 2021 5:23 pm

WaltBrown wrote:
Sat Mar 28, 2015 2:36 am
Here's a stack I use to find wayward stack windows in multi screen space - I sometimes park open stacks off screen. It may help.
Walt
just great!!! :D

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”