SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV Studio
Forum Rules FAQs Community Downloads Today's Posts Search

Notices

SageTV Studio Discussion related to the SageTV Studio application produced by SageTV. Questions, issues, problems, suggestions, etc. relating to the Studio software application should be posted here.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 02-09-2007, 03:27 PM
castylx castylx is offline
Sage User
 
Join Date: Nov 2006
Posts: 58
Modifying attributes on AfterMenuLoad hook

I'm trying to modify a local variable depending if the prior menu has a certain setting set. I'm using AddStaticContext(...); so I can pass the setting from menu1 onto menu2. I tried using BeforeMenuLoad hook which checks out the variable set by AddStaticContext, and then modifies my local variable depending on what menu1 did. However I can't seem to make the setting stick, or it's not going through....

Anyone tell me how to set a local variable before my panes are drawn on the screen? I also tried GetFocusContext() which also didn't work.

-- FC
Reply With Quote
  #2  
Old 02-09-2007, 03:34 PM
Opus4's Avatar
Opus4 Opus4 is offline
Administrator
 
Join Date: Sep 2003
Location: NJ
Posts: 19,624
You should be able to use the BeforeMenuLoad hook, since that is where making such settings are intended to be done before the menu finishes loading.

Is the name of the static context variable the same as the one used in the next menu, by any chance?

If not, what is the variable being used for? Does it control some UI setting?

- Andy
__________________
SageTV Open Source v9 is available.
- Read the SageTV FAQ. Older PDF User's Guides mostly still apply: SageTV V7.0 & SageTV Studio v7.1.
- Hauppauge remote help: 1) Basics/Extending it 2) Replace it 3) Use it w/o needing focus
- HD Extenders: A) FAQs B) URC MX-700 remote setup
Note: This is a users' forum; see the Rules. For official tech support fill out a Support Request.
Reply With Quote
  #3  
Old 02-09-2007, 03:39 PM
castylx castylx is offline
Sage User
 
Join Date: Nov 2006
Posts: 58
Quote:
Originally Posted by Opus4
You should be able to use the BeforeMenuLoad hook, since that is where making such settings are intended to be done before the menu finishes loading.

Is the name of the static context variable the same as the one used in the next menu, by any chance?

If not, what is the variable being used for? Does it control some UI setting?

- Andy
No the name is different. I know the static context variable is getting passed through correctly because the hook is actually called and I set a breakpoint where the attribute should change. However once it starts going through the menu and setting it up, the attribute never seems to take the value I set it to.

Would a testcase help?

-- FC
Reply With Quote
  #4  
Old 02-09-2007, 03:42 PM
castylx castylx is offline
Sage User
 
Join Date: Nov 2006
Posts: 58
Guess didn't answer the question completely, yes the variable is used to setup certain buttons.

-- FC
Reply With Quote
  #5  
Old 02-09-2007, 03:54 PM
Opus4's Avatar
Opus4 Opus4 is offline
Administrator
 
Join Date: Sep 2003
Location: NJ
Posts: 19,624
Quote:
Originally Posted by castylx
Would a testcase help?
There are so many things that could be happening... at least a screen shot of the lines in question might be useful. A sample STV if no one has any ideas after that.

Quote:
Originally Posted by castylx
Guess didn't answer the question completely, yes the variable is used to setup certain buttons.
Depending on what you are changing, you may need to reload the menu for the settings to take effect, such as when setting the number of columns or rows for tables. The Program Guide automatically reloads the menu in the BeforeMenuLoad hook if the table size needs ot be updated, for example.

- Andy
__________________
SageTV Open Source v9 is available.
- Read the SageTV FAQ. Older PDF User's Guides mostly still apply: SageTV V7.0 & SageTV Studio v7.1.
- Hauppauge remote help: 1) Basics/Extending it 2) Replace it 3) Use it w/o needing focus
- HD Extenders: A) FAQs B) URC MX-700 remote setup
Note: This is a users' forum; see the Rules. For official tech support fill out a Support Request.
Reply With Quote
  #6  
Old 02-09-2007, 04:10 PM
castylx castylx is offline
Sage User
 
Join Date: Nov 2006
Posts: 58
Quote:
Originally Posted by Opus4
There are so many things that could be happening... at least a screen shot of the lines in question might be useful. A sample STV if no one has any ideas after that.

Depending on what you are changing, you may need to reload the menu for the settings to take effect, such as when setting the number of columns or rows for tables. The Program Guide automatically reloads the menu in the BeforeMenuLoad hook if the table size needs ot be updated, for example.

- Andy
Here you go! So I set breakpoints and I know the setInfo is being set correctly...


Thanks for your help


-- FC
Attached Images
File Type: jpg studio2.jpg (40.8 KB, 219 views)
Reply With Quote
  #7  
Old 02-09-2007, 04:40 PM
Opus4's Avatar
Opus4 Opus4 is offline
Administrator
 
Join Date: Sep 2003
Location: NJ
Posts: 19,624
What are you trying to do with infoPanel? It is being set to false, but the pic only shows it being used leadinginto a panel... did you mean for that to be a conditional before the panel?

- Andy
__________________
SageTV Open Source v9 is available.
- Read the SageTV FAQ. Older PDF User's Guides mostly still apply: SageTV V7.0 & SageTV Studio v7.1.
- Hauppauge remote help: 1) Basics/Extending it 2) Replace it 3) Use it w/o needing focus
- HD Extenders: A) FAQs B) URC MX-700 remote setup
Note: This is a users' forum; see the Rules. For official tech support fill out a Support Request.
Reply With Quote
  #8  
Old 02-09-2007, 04:57 PM
castylx castylx is offline
Sage User
 
Join Date: Nov 2006
Posts: 58
Quote:
Originally Posted by Opus4
What are you trying to do with infoPanel? It is being set to false, but the pic only shows it being used leadinginto a panel... did you mean for that to be a conditional before the panel?

- Andy
Here is a better representation. I had the infoPanel there so I can change the variable manually and test out some stuff.

-- FC
Attached Images
File Type: jpg studio2.jpg (55.5 KB, 207 views)
Reply With Quote
  #9  
Old 02-09-2007, 05:39 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
Why do you have a second reference to the infoPanel attribute under your MainMenuContainer? By doing so you've effectively declared another variable called infoPanel masking the original infoPanel (the one you've initialized in BeforeMenuLoad).

I'm also not clear on why all the branches of your setInfo conditional do the same thing, or why you even need that conditional at all. If the idea is to initialize infoPanel to the inverse of setInfo, just say !setInfo directly in the attribute widget's Value property.

Also, just as a stylistic point, I prefer to arrange the widgets in the order they execute, i.e. attributes first, then BeforeMenuLoad, followed by the actual UI widgets. It doesn't matter to the code, but it does matter to the human being trying to read it and make sense of it.
__________________
-- Greg
Reply With Quote
  #10  
Old 02-09-2007, 07:02 PM
Opus4's Avatar
Opus4 Opus4 is offline
Administrator
 
Join Date: Sep 2003
Location: NJ
Posts: 19,624
Quote:
Originally Posted by GKusnick
Why do you have a second reference to the infoPanel attribute under your MainMenuContainer? By doing so you've effectively declared another variable called infoPanel masking the original infoPanel (the one you've initialized in BeforeMenuLoad).
I'll just reinforce that... this is the exact problem of why the variable doesn't have the expected value where you are using it.

- Andy
__________________
SageTV Open Source v9 is available.
- Read the SageTV FAQ. Older PDF User's Guides mostly still apply: SageTV V7.0 & SageTV Studio v7.1.
- Hauppauge remote help: 1) Basics/Extending it 2) Replace it 3) Use it w/o needing focus
- HD Extenders: A) FAQs B) URC MX-700 remote setup
Note: This is a users' forum; see the Rules. For official tech support fill out a Support Request.
Reply With Quote
  #11  
Old 02-09-2007, 07:25 PM
castylx castylx is offline
Sage User
 
Join Date: Nov 2006
Posts: 58
THANK YOU guys.... I got it working once I removed all the instances of infoPanel. Apologies for the questions, I'm very new to SageTV Studio, a bit confused how it all works (but learning). I was under the assumption that it worked like a programming language where you need the variable declared in every nest.... I did do the tutorial and read the docs, it's just one of those things that I missed....

BTW I can't set infoPanel to setInfo only because there are some entry points into this panel that do not set infoPanel to anything... hence the "if" statement for BeforeMenuLoad

-- FC
Reply With Quote
  #12  
Old 02-09-2007, 10:06 PM
Opus4's Avatar
Opus4 Opus4 is offline
Administrator
 
Join Date: Sep 2003
Location: NJ
Posts: 19,624
Quote:
Originally Posted by castylx
I was under the assumption that it worked like a programming language where you need the variable declared in every nest....
Actually, that would be one of the things similar to a 'regular' programming language... if you have a variable in one context and then define a new variable of the same name in a sub-context, that new variable will make the first one invisible in that sub-context, not inherit its value. Essentially: a local variable masks the global variable of the same name. (At least in the programming languages I'm familiar with.)

- Andy
__________________
SageTV Open Source v9 is available.
- Read the SageTV FAQ. Older PDF User's Guides mostly still apply: SageTV V7.0 & SageTV Studio v7.1.
- Hauppauge remote help: 1) Basics/Extending it 2) Replace it 3) Use it w/o needing focus
- HD Extenders: A) FAQs B) URC MX-700 remote setup
Note: This is a users' forum; see the Rules. For official tech support fill out a Support Request.
Reply With Quote
  #13  
Old 02-09-2007, 10:28 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
Quote:
Originally Posted by castylx
BTW I can't set infoPanel to setInfo only because there are some entry points into this panel that do not set infoPanel to anything... hence the "if" statement for BeforeMenuLoad
You can still handle that case directly in the Attribute widget:

Attribute: infoPanel
Value: If(setInfo != null, setInfo, false)

Or something like that. I'm not saying you have to do it this way. Obviously if your initialization logic doesn't fit neatly on one line, you're better off coding it using Conditional widgets. I just wanted to make sure that you're aware that (a) you can use arbitrary expressions in the Attribute widget's initial value, and (b) there's a one-line If function that's (somewhat) analogous to the ? : operator in C. (Actually it's more like VB's Iif function in that all arguments are evaluated.)
__________________
-- Greg
Reply With Quote
  #14  
Old 02-09-2007, 11:05 PM
Opus4's Avatar
Opus4 Opus4 is offline
Administrator
 
Join Date: Sep 2003
Location: NJ
Posts: 19,624
If you are setting some variable in a menu based on the value of a static context being set to that menu, you may be better off setting the variable's value in the BeforeMenuLoad hook. You are definitely better off initializing the local variables in the BeforeMenuLoad hook if using Global contexts to pass values.

SageTV caches the variables & so on used by a menu, so that the menus can load faster for subsequent visits. If a new static context is seen when the menu is loaded, the cache can be tossed & everything gets re-executed. If the static context values are all the same, but you previously calculated a different value for the local variable, it may not get reset to what your static context contains.

Global context contents don't affect the menu cache, so a local variable based on a global context really ought to be set in the BeforeMenuLoad hook.


It has been a while since I dealt with all this, so I hope I got the details right... but the point for my STV work is that it is just safer to use the BeforeMenuLoad hook to initialize local variables when they are based on outside-the-current-menu settings.

- Andy
__________________
SageTV Open Source v9 is available.
- Read the SageTV FAQ. Older PDF User's Guides mostly still apply: SageTV V7.0 & SageTV Studio v7.1.
- Hauppauge remote help: 1) Basics/Extending it 2) Replace it 3) Use it w/o needing focus
- HD Extenders: A) FAQs B) URC MX-700 remote setup
Note: This is a users' forum; see the Rules. For official tech support fill out a Support Request.
Reply With Quote
  #15  
Old 02-10-2007, 10:49 PM
castylx castylx is offline
Sage User
 
Join Date: Nov 2006
Posts: 58
Sounds good... another thing I didn't realize is that although the variable is seen as a "reference" it's actually not referred to... like a pointer. I had (in my original source) the same attribute in various sections, assuming the attributes were the same one (kinda like a pointer), so once I changed it on the BeforeMenuLoad hook it would stay no matter where I placed the attribute. Maybe I'm off on my whole logic, but it works, that's the important thing to me right now.

Thanks again.
Reply With Quote
  #16  
Old 02-10-2007, 10:59 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
No, a widget reference is not like a runtime pointer to a shared variable. It's more like a #define in C, a way of inserting multiple copies of the same code (or variable declarations) in several places, without actually having to copy and paste the code (and manually maintain all the separate copies).
__________________
-- Greg
Reply With Quote
  #17  
Old 02-10-2007, 11:22 PM
Opus4's Avatar
Opus4 Opus4 is offline
Administrator
 
Join Date: Sep 2003
Location: NJ
Posts: 19,624
Quote:
Originally Posted by castylx
I had (in my original source) the same attribute in various sections, assuming the attributes were the same one (kinda like a pointer), so once I changed it on the BeforeMenuLoad hook it would stay no matter where I placed the attribute.
In addition to what Greg said about references, check out chapter 4 of the Studio manual, starting on p. 50, which covers attributes/variables and their scope. They way to share the same variable between different sections of code is to define the attribute at a single point that is the parent of both places where you want to access it. (Hopefully, the manual is clear enough.)

If there is no shared parent _somewhere_ (i.e.: the variable is used in 2 different menus) then you have to use global context calls to allow both places to set & share the values.

- Andy
__________________
SageTV Open Source v9 is available.
- Read the SageTV FAQ. Older PDF User's Guides mostly still apply: SageTV V7.0 & SageTV Studio v7.1.
- Hauppauge remote help: 1) Basics/Extending it 2) Replace it 3) Use it w/o needing focus
- HD Extenders: A) FAQs B) URC MX-700 remote setup
Note: This is a users' forum; see the Rules. For official tech support fill out a Support Request.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 06:11 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.