You cannot invoke script on a secondary widget using scheduleActions or executeActions..... Script can only be invoked from a press of a UI button.
So, you'd do something like the following:
try
{
if (keyboardState == 0) // Unshifted
mySocket.send("a"); // assumes that socket variable is in scope.
else if (keyboardState == 1) // Shifted
mySocket.send("A"); // assumes that socket variable is in scope.
}
catch(e)
{
if (keyboardState == 0) // Unshifted
CF.widget("KeyA", "Unshifted").scheduleActions();
else if (keyboardState == 1) // Shifted
CF.widget("KeyA", "Shifted").scheduleActions();
}
Please have a look at this thread.
[Link: remotecentral.com]In the past, I've had thread subject lines edited where tips/good info apply to include [PS]. The above link is one of those threads.
Here's another thread that explains how to do 2 different actions on a single UI button. Very similar to what you started with.
[Link: remotecentral.com]I have authored several threads about the use of eval() and panel labels for purposes of storing common script in a configuration that can be executed later as needed.
If you need to execute a block of code instead of sending on a socket, you could use eval to execute script contained in panel label. For example,
CF.activity().eval(CF.widget('Script-KeyA', 'Unshifted').label);
where you create a Panel widget (with tag of 'Script-KeyA') on the same page (Unshifted page you previously created) containing Button with tag of 'KeyA'. The panel label could contain script. For example,
System.print("Hello World!!!");
Good luck.
Last edited by Lyndel McGee on January 8, 2012 21:43.