Your Universal Remote Control Center
RemoteCentral.com
Philips Pronto Professional Forum - View Post
Previous section Next section Up level
Up level
The following page was printed from RemoteCentral.com:

Login:
Pass:
 
 

Topic:
Script question
This thread has 8 replies. Displaying all posts.
Post 1 made on Tuesday March 17, 2009 at 14:43
pthornhill
Long Time Member
Joined:
Posts:
June 2008
53
I have a volume button (hard button) script that is looking for a widget on a page within same activity/device. The widget is always called "volbarpanel", and each device/activity can have multiple pages with different page script tags. Each page has the same "volbarpanel" widget.

How can I make the volume hard button reference the widget on the currently showing page? I have tried GUI.widget("volbarpanel") and it only gets a handle to the widget on the 1st page in the device that is viewed after entering the device/activity.

Same goes if I try CF.widget("volbarpanel",CF.activity().page().tag). It doesn't update handle if you switch between pages without coming out of the activity.

I don't want to manually give these widgets different tag names. Any suggestions?
Post 2 made on Tuesday March 17, 2009 at 17:40
Barry Gordon
Founding Member
Joined:
Posts:
August 2001
2,157
Your problem might be the fact that the script is on the hard key which is an activity level item. Since it is at the activity level I do not believe it can see things on pages. That is quite different than a soft key on a page calling a function at the activity level where that function is then running in the namespace of the page that called it.

The CF.page().tag is properly set, but the contents of that page are not in the namespace of the volume hard-key for the reason stated above. Hence the widget("volbarpanel",CF.page.tag())... can not be referenced.

The CF qualifier refers to the Configuration file which is static so that is not what you want unless you are trying to use it as a source as in var a=CF.widget(wtag,ptag).label.

In my work I always have all the code running in the context of a page's name space, the active pages namespace that is. I do this by putting all my code at the activity level and a page merely invokes code at the activity level. This code invoked by the page is a finite state machine (FSM). All soft-keys (page buttons) and Hard keys (real keys) make entries in a single queue which is flushed whenever a page starts. The queue is checked during the finite state machines execution and based upon whet the queue entry might say (e.g. "Volume,"Up") I perform a function which is defined at the activity level but since it is called from the FSM which is called cyclically by the active page it is then running in the context of the active pages namespace so it sees every widget on that page.

As a simpler solution you might try setting a variable defined at the activity level to be equal to the volbarpanel widget of the current page as part of each page's start up code. It would be the same line of code on each page. In that manner the activity level reference which can be seen in the volume Hard key code should be correct. This in effect gives you a pointer to the widget but the pointer is defined at the activity level where it needs to be.


Hope the above explains it.

Last edited by Barry Gordon on March 17, 2009 21:18.
Post 3 made on Tuesday March 17, 2009 at 20:36
mraneri
Long Time Member
Joined:
Posts:
February 2009
141
The following works for me... Seems like it should apply to your application as well. There may be other ways..

page().widget("volbarpanel").visible = true;
OP | Post 4 made on Wednesday March 18, 2009 at 14:36
pthornhill
Long Time Member
Joined:
Posts:
June 2008
53
thanks guys - very much appreciate your responses. Will be trying out these different approaches over next few days and will let you know what ends up working.

....it WILL end up working, even if i have no hair left when I've managed it ;-)
Post 5 made on Thursday March 19, 2009 at 16:24
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,997
Did you try defining the variable at activity level and then using the page script to assign the variable as follows:

myWidget = this.widget("widgettag");

This way, when you jump to a page that has the widget, the correct one should be chosen. Also, on pages where this widget might not be present, set myWidget to null.

myWidget = null;
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 6 made on Tuesday March 24, 2009 at 06:27
pthornhill
Long Time Member
Joined:
Posts:
June 2008
53
thanks mraneri - that line of script worked perfectly in the hard buttons:

page().widget("volbarpanel").visible = true;

I also found that in order for the functions defined at activity level to work with the page objects, when the function was called by a hard button, I had to pass the page().widget object refs to the activity level functions in order for the functions to refer to the widgets on the current page visible.

I tried defining my vars at activity level, and setting them using the page script on each page. However the hard buttons still did not refer to the widgets on page currently visible. They only ever pointed at the widgets on the first page in the device accessed.

Anyway - it works. Many thanks to all for your helpful insight and advice.
Post 7 made on Tuesday March 24, 2009 at 08:18
mraneri
Long Time Member
Joined:
Posts:
February 2009
141
Glad to hear it worked for you.

Another trick I've used, which may help you, depending on exactly what your trying to accomplish is to pass control from the activity to a function on the currently active page.. So, in my soundbridge (Similar to Slimpronto) activity, I detect a song change at the activity level, and then call the "SongChanged" function on whichever page is active... Something like this...

if (page().SongChanged != null) page().SongChanged();

On pages where I don't care if the song changed, I never declare the function, and it never gets called. And on pages where I do, I can take the appropriate action. This way, I can still keep all the specific page code at the page level, and easily pass control from the activity to the current page.
Post 8 made on Tuesday March 24, 2009 at 22:48
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,997
All this is great unless your script is larger than 32KB (PEPV2) or 64KB (PEPV1). If this is the case, then your only option is to use eval() to compile the content of panel labels.
Lyndel McGee
Philips Pronto Addict/Beta Tester
Post 9 made on Wednesday March 25, 2009 at 08:17
mraneri
Long Time Member
Joined:
Posts:
February 2009
141
Thanks, Lyndel. This is good to know. How do we know we've hit the limit?

I'm using eval to execute blocks of code regularly as well. Do you know if there's a simlar limit on the size of text in a panel label?


Jump to


Protected Feature 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.

Hosting Services by ipHouse