Backdrop behaves differently depending on how LC is started

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
AtoZ
Posts: 64
Joined: Tue Mar 06, 2012 8:31 am

Backdrop behaves differently depending on how LC is started

Post by AtoZ » Tue Aug 28, 2012 7:46 pm

When a user opens my stack, I want to preserve whatever backdrop the user is currently using and then change it to my preference for a backdrop while my stack is running. Then when stack closes, I restore the backdrop to the user's original setting. I currently use the following code when my stack opens:

Code: Select all

global gPreviousBackdrop

on preOpenStack
    put the backdrop into gPreviousBackdrop  -- Stores the backdrop setting on opening the stack
    set the backdrop to "128,128,128"        -- Set the backdrop to a gray color 
end preOpenStack
When a closeStackRequest is received, I restore the original backdrop.

This works fine IF I first open LiveCode and then open the stack from within LiveCode. But if I double-click on the stack to open it from the Desktop, the code is ignored and the user's backdrop remains.

I've tried moving the code to the openStack handler, with the same results.

Any suggestions as to how to always be able to save the user's backdrop and use my own?
Using LiveCode 5.5 on Windows 7 Home Premium Edition, Service Pack 1

Image
On my way from A TO Z, I often end up AT OZ.

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Backdrop behaves differently depending on how LC is star

Post by shaosean » Tue Aug 28, 2012 8:02 pm

When opening from the desktop, do the preOpenStack and openStack messages fire? If they do, just move your code in to another handler and then use a send in 0 milliseconds command..

AtoZ
Posts: 64
Joined: Tue Mar 06, 2012 8:31 am

Re: Backdrop behaves differently depending on how LC is star

Post by AtoZ » Tue Aug 28, 2012 8:43 pm

Thanks for your quick response.

Not sure the best way to see if the handlers fire. What I did was place a line of code at the start of the preOpenStack handler that says: put "START" and a second line at the end of the handler that says: put " FINISH" after msg

When I opened the stack from the desktop the two words appeared in the message box, so it would appear the handler is firing. I know that the openStack handler is firing because it sets all my initial global values correctly.

I tried various ways to use the send command as you suggested, but keep getting compile errors, and I wasn't really sure where to put them. I not at all clear why this should work when then standard commands do not.

I would appreciate any further help you could give me.
Using LiveCode 5.5 on Windows 7 Home Premium Edition, Service Pack 1

Image
On my way from A TO Z, I often end up AT OZ.

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Backdrop behaves differently depending on how LC is star

Post by sturgis » Wed Aug 29, 2012 12:37 am

Try what shaosean suggested, take the code that adjusts your backdrop and put it into its own handler

Code: Select all

command setBackDrop
  put the backdrop into gPreviousBackdrop  -- Stores the backdrop setting on opening the stack
    set the backdrop to "128,128,128"        -- Set the backdrop to a gray color 
end setBackDrop
Then in your preopenstack do this

Code: Select all

on preOpenStack
   send "setBackDrop" to me in 0
end preOpenStack
See if it solves the problem.

AtoZ
Posts: 64
Joined: Tue Mar 06, 2012 8:31 am

Re: Backdrop behaves differently depending on how LC is star

Post by AtoZ » Wed Aug 29, 2012 3:40 am

Thanks very much for the explanation. That does the trick, although I don't understand why it's necessary to do this in such a roundabout way.

There is one small problem left that I'm not sure will have a solution:

When I open the stack by double-clicking it's icon, LiveCode opens for a brief moment with my standard backdrop color and then quickly switchs to the new backdrop. It makes the screen flicker a little. I tried adding a lock screen command at the start of the preOpenStack handler, but that doesn't help. Apparently the backdrop color set in the user's preferences gets accessed and displayed before the preOpenStack handler runs. As I said, I'm doubtful there's a way around this, but it never hurts to ask -- you guys know so much more than I do about LiveCode.

Thanks again for your help.
Using LiveCode 5.5 on Windows 7 Home Premium Edition, Service Pack 1

Image
On my way from A TO Z, I often end up AT OZ.

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Backdrop behaves differently depending on how LC is star

Post by shaosean » Wed Aug 29, 2012 6:00 am

Are you changing the backdrop colour before showing the backdrop?

AtoZ
Posts: 64
Joined: Tue Mar 06, 2012 8:31 am

Re: Backdrop behaves differently depending on how LC is star

Post by AtoZ » Wed Aug 29, 2012 9:08 am

I'm doing it just the way Sturgis suggested above: I save the current backdrop and then change the backdrop color -- from a handler called in the preOpenStack script. That call is the first line in the preOpenStack handler.

I wouldn't know how to change the backdrop color before displaying it. That's what I was asking about actually: is there a way to change the backdrop color before the usher's backdrop preference is displayed? (I suspect not.)

Looking forward to any suggestions.
Using LiveCode 5.5 on Windows 7 Home Premium Edition, Service Pack 1

Image
On my way from A TO Z, I often end up AT OZ.

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Backdrop behaves differently depending on how LC is star

Post by Klaus » Wed Aug 29, 2012 12:18 pm

Hi AtoZ,

there is one thing I don't understand.
You wrote:
When a user opens my stack, I want to preserve whatever backdrop the user is currently using...
Are you talking about standalones or stacks that other LiveCode users will open in the IDE?

Most problems in the IDE do not exist in a standalone, like "preopenstack" not executed when doubleclicking the stack on the desktop.
And only LiveCode standalones (and stacks) can have a BACKDROP that you can control.
WHERE is the users default backdrop setting you are talking about?

I am trying to understand what this is all about 8)


Best

Klaus

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Backdrop behaves differently depending on how LC is star

Post by jacque » Wed Aug 29, 2012 8:00 pm

Setting the backdrop color also displays it, so you're doing the right thing. It sounds like you've set a backdrop in the IDE in your own preferences and that's what you're seeing.

I think your stack is behaving the only way it can. When opening it from the desktop, LiveCode will start up first, then the IDE will load, and you'll see the default backdrop you've assigned. After LiveCode and the IDE are done loading, the stack will open and load, and at that point your stack's backdrop will take effect.

As Klaus mentioned, there is no default backdrop in a standalone. That's strictly an option in the IDE. If you are building a standalone, your custom backdrop will display as soon as your stack opens.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

AtoZ
Posts: 64
Joined: Tue Mar 06, 2012 8:31 am

Re: Backdrop behaves differently depending on how LC is star

Post by AtoZ » Wed Aug 29, 2012 8:13 pm

Thanks guys,

I sometimes forget that things work differently in a standalone than in LiveCode. Since the stack will ultimately be a standalone, there will not be a problem with the backdrop there, so I won't let the momentary display of the user's preferred backdrop while still in LiveCode give me any concern.

Thanks everyone, as usual you've been a great help.
Using LiveCode 5.5 on Windows 7 Home Premium Edition, Service Pack 1

Image
On my way from A TO Z, I often end up AT OZ.

Post Reply