|
|
|
The following page was printed from RemoteCentral.com:
Topic: | Widget Referencing? This thread has 8 replies. Displaying all posts. |
|
Post 1 made on Saturday April 11, 2009 at 09:01 |
I have an RC9001 which I am trying to improve on the installer's default programming. I am not a programmer but have some basic knowledge of JavaScript.
Using Herb Crane's downloadable example (thank you), I have successfully created a widget to operate my Rako lighting UP/DOWN controls using the rotary wheel. My question is where should I put the widget page so that the UP and DOWN commands can be accessed irrespective of what page the remote is on. At present I have the widget page under my Pioneer Blu-Ray device but would like the rotary wheel to work eg when the RC9001 is on the Home or Sky pages. Or do I just need to copy the widget page and script to each device?
Usual apologies for dumb newbie question but thanks in advance.
|
|
Post 2 made on Saturday April 11, 2009 at 10:59 |
Guy Palmer Active Member |
Joined: Posts: | June 2008 648 |
|
|
You can put the widget page anywhere but the scripts then need a full reference, including the activity i.e. ("button name","page name","activity name").
I think the script has to be in every activity.
So: only one widget page but one script per activity.
|
|
OP | Post 3 made on Saturday April 11, 2009 at 13:45 |
Hi Guy,
Thanks very much for your advice. I had gone back to RTM and found similar advice under the CF class widget() but still can't get it to work. I suspect I have a syntax error either in the function itself (now it is removed to a dummy Rako device page) or in calling it from another device/activity.
What I have is the following:
A dummy hidden device: RAKO_WIDGET
This contains a ProntoScript Name: RAKO_UPDOWN with the following script (a direct lift from Herb Crane's example and needing more work eg accelerators for multiple clicks but works ok when the widget page is put with the device):
onRotary = function(clicks) { if (clicks == 1) {CF.widget("Lights_Up","WidgetPage").executeActions();} if (clicks == -1) {CF.widget("Lights_Down","WidgetPage").executeActions();} };
RAKO_WIDGET has a page called WidgetPage which holds the Lights_Up and Lights_Down buttons which work ok.
My problem is now what code to put in each devices' property page to call the widget buttons?
If I put this code in the SkY property page the lights do not come on when the rotary wheel is turned:
onRotary = CF.widget("RAKO_UPDOWN", "WidgetPage", "RAKO_WIDGET");
I have tried a number of variations but can only guess that I am not calling the function correctly. Grateful any further advice.
Regards
|
|
Post 4 made on Saturday April 11, 2009 at 14:02 |
mraneri Long Time Member |
Joined: Posts: | February 2009 141 |
|
|
You have to put the following code in every activity:
onRotary = function(clicks) { if (clicks == 1) {CF.widget("Lights_Up","WidgetPage","RAKO_ACTIVITY").executeActions();} if (clicks == -1) {CF.widget("Lights_Down","WidgetPage","RAKO_ACTIVITY").executeActions();} };
Note also, You need to add the activity where the Lights_Up and Lights_Down buttons are. When you call CF.widget with just a button tag and a page tag, it only looks in the current activity. You need to specify the activity where the buttons are. Make sure the activity has the prontoscript name defined, and make it match the function calls above...
- Mike
|
|
OP | Post 5 made on Saturday April 11, 2009 at 15:50 |
Hi Mike,
Thanks for the advice and sorry to labour this but I still can't get it working! I understand the need for referencing. The buttons are in the activity RAKO_WIDGET so I guess the code for each activity is:
onRotary = function(clicks) { if (clicks == 1) {CF.widget("Lights_Up","WidgetPage","RAKO_WIDGET").executeActions();} if (clicks == -1) {CF.widget("Lights_Down","WidgetPage","RAKO_WIDGET").executeActions();} };
But I am still confused as to what script (if anything) I put in the RAKO_WIDGETS property page. I currently have my original code:
function(clicks) { if (clicks == 1) {CF.widget("Lights_Up","WidgetPage").executeActions();} if (clicks == -1) {CF.widget("Lights_Down","WidgetPage").executeActions();} };
Is this now redundant as the buttons are now being called directly from each activity? And if not what should the ProntoScript Name for any script be, given that it is function(clicks) which is called? (For reference, the WidgetPage and Lights_Up and Lights_Down buttons have the same PS Name as their labels.)
Thanks and regards
Steve
|
|
Post 6 made on Saturday April 11, 2009 at 15:51 |
Guy Palmer Active Member |
Joined: Posts: | June 2008 648 |
|
|
Vix,
Mike is right and he is saying what I was trying to say. The onrotary script has to be in every activity. You seem to be trying to add an extra layer of scripting but scripts only operate within activities (although they can reference buttons in other activities).
So, leave your Lights Up/Down buttons as they were, add the activity name to the references in the onrotary script and copy this script to each activity where you want to use it.
|
|
Post 7 made on Saturday April 11, 2009 at 16:22 |
mraneri Long Time Member |
Joined: Posts: | February 2009 141 |
|
|
All you need is the script in each activity as you have it, and the two buttons on the "WidgetPage" page in the "RAKO_WIDGET" activity. No code is required in the RAKO activity.
If it's still not working, verify: 1) The "ProntoScript Name" of the RAKO Activity is "RAKO_WIDGET". 2) The "ProntoScript Name" of the Page with the two buttons on it is "WidgetPage". 3) And the "ProntoScript Name" of the two buttons on WidgetPage are "Lights_Up" and "Lights_Down".
If all this looks ok, the script should work. (Also note, that if you turn the rotary too fast, clicks can be +2 or +3, or -2, -3, etc... So you may want to change your if's to clicks>0 and clicks<0.
|
|
OP | Post 8 made on Sunday April 12, 2009 at 07:03 |
Mike and Guy, Changes made and all now working! Thanks for all your advice. Steve
Last edited by Vix on April 12, 2009 07:21.
|
|
Post 9 made on Sunday April 12, 2009 at 11:26 |
Lyndel McGee RC Moderator |
Joined: Posts: | August 2001 13,001 |
|
|
I know this has been mentioned above. However, for Widget Referencing to work, you MUST always supply a ProntoScript name and it is critical that you understand that the label and the ProntoScript name (aka tag) are not the same. Note, that if you are referencing widgets on different pages or in different activities, the pages as well as the activities containing the widgets MUST have ProntoScript names as well.
Last edited by Lyndel McGee on April 12, 2009 14:50.
|
Lyndel McGee Philips Pronto Addict/Beta Tester
|
|
|
Before you can reply to a message... |
You must first register for a Remote Central user account - it's fast and free! Or, if you already have an account, please login now. |
Please read the following: Unsolicited commercial advertisements are absolutely not permitted on this forum. Other private buy & sell messages should be posted to our Marketplace. For information on how to advertise your service or product click here. Remote Central reserves the right to remove or modify any post that is deemed inappropriate.
|
|