Page 1 of 1

Backdrop behaves differently depending on how LC is started

Posted: Tue Aug 28, 2012 7:46 pm
by AtoZ
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?

Re: Backdrop behaves differently depending on how LC is star

Posted: Tue Aug 28, 2012 8:02 pm
by shaosean
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..

Re: Backdrop behaves differently depending on how LC is star

Posted: Tue Aug 28, 2012 8:43 pm
by AtoZ
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.

Re: Backdrop behaves differently depending on how LC is star

Posted: Wed Aug 29, 2012 12:37 am
by sturgis
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.

Re: Backdrop behaves differently depending on how LC is star

Posted: Wed Aug 29, 2012 3:40 am
by AtoZ
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.

Re: Backdrop behaves differently depending on how LC is star

Posted: Wed Aug 29, 2012 6:00 am
by shaosean
Are you changing the backdrop colour before showing the backdrop?

Re: Backdrop behaves differently depending on how LC is star

Posted: Wed Aug 29, 2012 9:08 am
by AtoZ
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.

Re: Backdrop behaves differently depending on how LC is star

Posted: Wed Aug 29, 2012 12:18 pm
by Klaus
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

Re: Backdrop behaves differently depending on how LC is star

Posted: Wed Aug 29, 2012 8:00 pm
by jacque
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.

Re: Backdrop behaves differently depending on how LC is star

Posted: Wed Aug 29, 2012 8:13 pm
by AtoZ
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.