Page 1 of 1
Disabling all controls in stack..
Posted: Wed Jan 07, 2015 4:18 pm
by tasdvl9
Hi All,
I'm trying to implement a timeout feature which will disable all of the controls in a specific stack once the time has elapsed.
Is there a way to do this?
I was hoping to just disable the stack and that would also disable my controls but I don't think this is the case.
Thanks!
Re: Disabling all controls in stack..
Posted: Wed Jan 07, 2015 4:26 pm
by Klaus
Hi tasdvl9,
you cannot disable stacks or cards!
You'd need to:
1. loop over all controls in your stack/card and disable them.
Or
2. Simply create a filled graphic, with any blendlevel set, in the size of your card,
that you simply show in your stack on top of all controls
Best
Klaus
Re: Disabling all controls in stack..
Posted: Wed Jan 07, 2015 4:28 pm
by jmburnod
Hi tasdvl9,
You can of course disable all controls like this:
1. Building a list of all controls of each cd of your stack
2. Launch a loop to disable each control
but display a button transparent at the rect of cd will be easier
Best regards
Jean-Marc
Re: Disabling all controls in stack..
Posted: Wed Jan 07, 2015 4:42 pm
by tasdvl9
Thanks, All.
I'll give that a go!
Re: Disabling all controls in stack..
Posted: Wed Jan 07, 2015 5:51 pm
by FourthWorld
An overlay object is a good solution to prevent mouse clicks, but may not prevent keyboard access for any controls whose traversalOn property is set.
To truly disable all controls (and have their appearances updated accordingly) you can group them and then enable/disable the group.
To group them, in the IDE choose Edit->Select All, then Object->Group Selected. You may want to name the group in the Property Inspector.
At runtime, enabling or disabling them is just one line:
...or:
Re: Disabling all controls in stack..
Posted: Wed Jan 07, 2015 10:25 pm
by Klaus
Hi Richard,
FourthWorld wrote:An overlay object is a good solution to prevent mouse clicks, but may not prevent keyboard access for any controls whose traversalOn property is set.
ah, yes, good catch!
Best
Klaus
Re: Disabling all controls in stack..
Posted: Thu Jan 15, 2015 11:26 am
by uelandbob
Would it be possible to create a frontScript that trapped all mouse and keyDown events? Just a thought*.
Here is a little experiment you can do. Create a stack and on a card, add two buttons called "answer" and "myFront". Make their scripts look like this:
Code: Select all
-- answer
on mouseUp
answer "How are you?"
end mouseUp
Code: Select all
-- myFront
on mouseUp
put "trapped mouseUp"
end mouseUp
on mouseDown
put "trapped mouseDwn"
end mouseDown
in the card script write a handler
Code: Select all
-- card
on commandKeyDown theKey
if (the shiftKey is down) then
if theKey = "a" then
beep
insert script of button "myFront" into front
else
beep 2
remove the script of btn "myFront" from front
end if
else
pass commandKeyDown theKey
end if
end commandKeyDown
Test that it works
1. Click on the answer button. A dialog box should appear. Dismiss it.
2. Press Cmd+Shift+a. This will activate the frontScript.
3. Click on the answer button. Nothing happens, proving that frontScript swallows the mouseDown and mouseUp.
4. Press Cmd+Shift+r. This will remove the frontScript.
5. Click on the answer button. A dialog box should appear. Dismiss it.
You could do similar things for keyDown, and other events that you want to trap.
Warning: I am not super familiar with frontScript yet, and it is little tricky. In theory it sounds nice, but in practice it could prove to be more complicated than it appears at first glance. So always experiment in a new stack or if you experiment in an existing stack, make sure to take a copy. Things could lock themselves up and drive you crazy
*The overlay solution is easier and more elegant, and in a real situation I would use it. But to play with and get familiar with frontScript is also good, because you'll never know when you'll need it.
