Location of stack

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
pderocco
Posts: 44
Joined: Fri May 16, 2008 1:26 am

Location of stack

Post by pderocco » Sat May 15, 2010 5:02 pm

In my program, I write the location of my stack (among other things) to a text file on exit, and then read it and set the location on startup. This works correctly on Windows, but on the Mac, the window moves up by 12 pixels every time. This happens both when I run the .rev file or when I run my standalone. I use 'the location of stack "main"' to get and set the location. I'm using Rev 3.5. Is this a known bug?
Ciao,
Paul

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Location of stack

Post by Mark » Mon May 17, 2010 1:44 pm

Hi Paul,

The engine knows the actual height of the card only after loading all windows, objects, libraries etc. This is easy to solve, by first running all default startup messages (preOpenStack, openStack, preOpenCard, openCard, openBackground etc.) and changing the window size only afterwards. For example:

global gWindowRect

Code: Select all

on preOpenStack
  hide this stack
  readPrefs // your handler to read prefs
  send "setWindowSize" to me in 0 millisecs
  pass preOpenStack
end preOpenStack

on setWindowSize
  set the rect of this stack to gWindowRect
end setWindowSize
Instead of a handler that only sets the rect of the window, you could also write a handler that does the complete initialisation of your project. It is safe to assume that all necesary libraries are available when the initialisation handler runs.

I'm not sure that this is actually a bug, but it is definitely rather inconvenient. I think that the engine should be aware of the menu before it starts sending the startUp and other messages.

I'll post this answer to the Use List too.

Best regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Post Reply