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 11-05-2007, 04:06 PM
perry59's Avatar
perry59 perry59 is offline
Sage Advanced User
 
Join Date: Oct 2007
Location: oregon, usa
Posts: 76
Another rollover question

Im trying to implement a simple "rollover" scheme whereas I have a panel with several image buttons in it and as a button is focused another image appears in another panel. This has been asked before and I followed the suggestions in that post, but its still not quite right. When Im in the panel with the buttons I actually have to click on one, then shift focus away from it before its picture appears in the other panel. then of course, its the wrong picture!
Can someone tell me what I've done wrong here?
Attached is a small clip from studio showing the code.
Thanks!
Attached Images
File Type: jpg untitled.JPG (44.7 KB, 182 views)
Reply With Quote
  #2  
Old 11-05-2007, 04:10 PM
Opus4's Avatar
Opus4 Opus4 is offline
Administrator
 
Join Date: Sep 2003
Location: NJ
Posts: 19,624
First, you could just set an attribute (variable) under each button, defining the filename of that button's image file. This is probably the simplest solution. Don't put the HoverImage attribute widget under a parent common to both buttons.

Second, the way you have it set up, the code to set the hover image won't get run until you select the item, as you've noticed. To run code when the button gets focus, use the FocusGained hook. (Remember: if you ever do any Refresh or RefreshArea calls in the FocusGained hook, you have to call Fork() before calling Refresh() - there is a sticky about that in this forum section.)

- 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 11-05-2007, 09:40 PM
perry59's Avatar
perry59 perry59 is offline
Sage Advanced User
 
Join Date: Oct 2007
Location: oregon, usa
Posts: 76
Thanks for the help Andy.
I thought I had this coded correctly, like what was described in this post
http://forums.sagetv.com/forums/show...light=rollover
but it wasnt quite there. Not sure why I would have to have a variable under each button if each button had an action widget to set the value of a variable shared by all buttons...
I also assume you mean for the FocusGained hook to be in each button, how is this different from the "if focused" statement?
Anyway, what I did was to put a "hoverimage" variable under each button and under that I put a FocusGained hook and as a child of the FocusGained I added an action widget which call "ExecuteWidget" with my HoverPanel as a parameter. Seems to work great now, and there was no need to call "Refresh()"
PS, is that correct, putting the action widget under the FocusGained hook calling the executewidget code?
Reply With Quote
  #4  
Old 11-05-2007, 10:00 PM
Opus4's Avatar
Opus4 Opus4 is offline
Administrator
 
Join Date: Sep 2003
Location: NJ
Posts: 19,624
Quote:
Originally Posted by perry59 View Post
Not sure why I would have to have a variable under each button if each button had an action widget to set the value of a variable shared by all buttons...
You don't need the variable under each button if you are going to set the value when the item gains focus, but only the FocusGained hook's child widgets will automatically get called when the button gains focus. Your action chain under "If Focused" was not a UI chain, since it contained no child UI widgets, so it was an action chain, which only gets executed when the button is selected, not when it gains focus.

If the variable/attribute is defined under each button, then GetFocusContext() will get the variable values for the currently focused item when focus changes & you will automatically get the value w/o needing the FocusGained hook.

Quote:
I also assume you mean for the FocusGained hook to be in each button, how is this different from the "if focused" statement?
See my comment above.

Quote:
Anyway, what I did was to put a "hoverimage" variable under each button and under that I put a FocusGained hook and as a child of the FocusGained I added an action widget which call "ExecuteWidget" with my HoverPanel as a parameter. Seems to work great now, and there was no need to call "Refresh()"
PS, is that correct, putting the action widget under the FocusGained hook calling the executewidget code?
I don't understand... you somehow managed to get the FocusGained hook to be a child of the attribute widget, or what? And, what do you mean by "ExecuteWidget"?

You need nothing under each button other than either 1) an attribute defining the variable for that buttons value, or 2) a FocusGained hook setting the variable's value, if the varibale is defined somewhere above the buttons. (#1 is just easier.)

There is no need for a refresh call since you are using GetFocusContext(). (I shouldn't have mentioned the info about Refresh()... it was just in case you ever tried that call under a FocusGained hook. But, all I did was add confusion, so ignore my previous comment about refresh in this topic.)

- 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
  #5  
Old 11-06-2007, 03:45 AM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
I've attached a screenshot illustrating various ways of doing it.

In method 1, putting an attribute under each item lets you define the attribute values statically (as shown in the square brackets) and enables GetFocusContext to automatically select the appropriate value for the focused item without any additional code on your part. Think of this as the object-oriented approach, with each item being like an instance of a class with a property called Image. Each instance has its own copy of the property variable. The code under GetFocusContext is effectively invoking that property on the focused item.

Method 2 is more of a procedural style of coding. There's only one attribute, defined at the menu level where everyone can see it. Event handlers under each item explicitly set the attribute value and explictly call RefreshArea on the panel that needs to be redrawn as a result. There's nothing for GetFocusContext to do in this case, since the context for all items is identical (i.e. no item-specific attributes).

Method 3 is a sort of hybrid approach. It still uses the procedural method of choosing the image as in method 2, but exploits a side-effect of GetFocusContext to get Panel 2 refreshed, instead of calling RefreshArea explicitly. I consider this method a bit of a kluge on two counts: First, it's using GetFocusContext only for its side-effects, and not for its primary purpose (retrieving the item context, which in this case is the same for all items). Second, it assumes that the FocusGained hook will fire before the refresh entailed by GetFocusContext. This assumption may very well be correct, but it's an additional timing dependency that neither of the other two methods has.

So my preference would be for method 1 as the simplest and most straightforward expression of the intention. Method 2 would be an acceptable (if rather more verbose) alternative. Method 3 I would tend to avoid for the reasons given above.
Attached Images
File Type: png Example.png (29.5 KB, 169 views)
__________________
-- Greg
Reply With Quote
  #6  
Old 11-06-2007, 12:50 PM
perry59's Avatar
perry59 perry59 is offline
Sage Advanced User
 
Join Date: Oct 2007
Location: oregon, usa
Posts: 76
Thanks

Thanks a bunch guys.
Andy, your second post really cleared it up for me. I re-read the section on widget chain types (Believe it or not, I read the studio manual front to back before starting this) and the light went on. I see now why my first try with the "if focused" thing didnt work as a "rollover" but the GetFocused hook does. (oh, I meant "ExecuteWidgetChain" in my second post, see my attached images). So now, my third stab at this is more like Andy suggested and looks a lot like Greg's example but with no need to call "Refresh".
So thanks again guys, this really helped! Im keeping all these posts and images in my Sage notebook, and hopefully this lays it out clearly for other noobs
The only other issue I have with this setup is that in my main menu, where the images only show a couple buttons I actually have about a dozen buttons. Several buttons then are outside the panels bounds and not visible. I set the panel to scroll so that when the bottom most visible button is hightlighted you can hit the down key and the previously hidden buttons come into view one at a time and the top most buttons "go away". The problem with this is they wont "wrap". If I check the "wrap vertical navigation" it doesnt work unless I uncheck the scroll vertical box. But then of course the buttons no longer scroll and if you down key past the bottom most visible button, the buttons below that down scroll into view (but my hoverimage panel still shows the image for the current button).
I guess in this case I cant have my cake and eat it too eh?
Greg, as an aside, I downloaded your studio tools. Put the .jar file into SageTv/Jars and the "gkusnick.sagetv" folder into the SageTv folder (right beside the Jars, STV's, etc folders) but I see no other options in Studio.
What have I done wrong?
Thanks
Attached Images
File Type: jpg first try.JPG (51.8 KB, 142 views)
File Type: jpg second try.JPG (57.3 KB, 147 views)
File Type: jpg third try.JPG (64.2 KB, 160 views)
Reply With Quote
  #7  
Old 11-06-2007, 01:22 PM
evilpenguin's Avatar
evilpenguin evilpenguin is offline
SageTVaholic
 
Join Date: Aug 2003
Location: Seattle, WA
Posts: 3,696
You just have to add a line to the properties file and you should be good to go.

Quote:
To enable the plugin manager, add gkusnick.sagetv.studio.Inject to the load_at_startup_runnable_classes property on the system where you do your Studio development (i.e. your SageClient properties, not your SageTV service properties).
Quote:
load_at_startup_runnable_classes=gkusnick.sagetv.studio.Inject
Reply With Quote
  #8  
Old 11-06-2007, 01:45 PM
perry59's Avatar
perry59 perry59 is offline
Sage Advanced User
 
Join Date: Oct 2007
Location: oregon, usa
Posts: 76
Ah thanks EP, that did it!
Reply With Quote
  #9  
Old 11-06-2007, 01:49 PM
Opus4's Avatar
Opus4 Opus4 is offline
Administrator
 
Join Date: Sep 2003
Location: NJ
Posts: 19,624
BTW: you can use offset paths from the STV's location for the image files. If you use full paths, they won't work if the STV is used on another system or if you change your install location on any of your own systems.

Or, you could add your own images to the theme system & access them via the FocusGained hook w/their global variables.

- 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
  #10  
Old 11-06-2007, 01:56 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
Just in case you haven't figured this out yet, the ExecuteWidgetChain call in your second try doesn't do remotely what you think it does. For one thing, it's expecting a Widget object as an argument, and what you've passed it is basically null, i.e. a reference to a variable (HoverPanel) that's not defined anywhere. Simply naming a Panel widget HoverPanel does not declare a variable of type Widget with a reference that panel as its value. Only Attribute widgets declare variables. In order to get a Widget object to pass to ExecuteWidgetChain, you would have to use WidgetAPI calls to navigate the widget tree.

But in any case, ExecuteWidgetChain isn't really what you want here. It's meant to apply to Action chains that calculate values and is mainly used interactively during debugging. To refresh a UI widget, use RefreshArea (with the caveat that Andy mentioned earlier about forking when called from a FocusGained or FocusLost hook).

Misusing API calls generally results in exceptions being thrown. To see these exceptions, make sure the Notify on Errors checkbox is checked on the Tools menu in Studio. To see a stack trace, check your debug log, or run with a console window open. You can enable the console window in the registry as follows:

Code:
[HKEY_LOCAL_MACHINE\SOFTWARE\Frey Technologies\Common]
"consolewin"=dword:00000001
__________________
-- Greg
Reply With Quote
  #11  
Old 11-06-2007, 03:36 PM
perry59's Avatar
perry59 perry59 is offline
Sage Advanced User
 
Join Date: Oct 2007
Location: oregon, usa
Posts: 76
Quote:
Originally Posted by Opus4 View Post
BTW: you can use offset paths from the STV's location for the image files. If you use full paths, they won't work if the STV is used on another system or if you change your install location on any of your own systems.

Or, you could add your own images to the theme system & access them via the FocusGained hook w/their global variables.

- Andy
Actually, I was going to ask about that but didnt want to bombard forum with so many questions at once
I was thinking of creating a global variable, say, one called "RootDir" and using the application started hook to initialize it to the location of the current stv. Then just use a modified version of that variable for loading images, etc.
I would have thought that something similar would be in virtually every stv, yet I have not seen such a construct so far...
Reply With Quote
  #12  
Old 11-06-2007, 03:41 PM
perry59's Avatar
perry59 perry59 is offline
Sage Advanced User
 
Join Date: Oct 2007
Location: oregon, usa
Posts: 76
Quote:
Originally Posted by GKusnick View Post
Just in case you haven't figured this out yet, the ExecuteWidgetChain call in your second try doesn't do remotely what you think it does.
It was just a shot in the dark, I did have a gut feeling I was doing a no-no.
Thanks for the additional info. Every little bit helps
Reply With Quote
  #13  
Old 11-06-2007, 04:10 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
Quote:
Originally Posted by perry59 View Post
I was thinking of creating a global variable, say, one called "RootDir" and using the application started hook to initialize it to the location of the current stv. Then just use a modified version of that variable for loading images, etc.
I would have thought that something similar would be in virtually every stv, yet I have not seen such a construct so far...
What Andy's saying is that you don't need to do the path calculus yourself. Just pass in partial paths to the Image widgets and they'll automatically be interpreted relative to the directory containing the STV.
__________________
-- Greg
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Freezes/pauses in SageTV after changing channel and question about Client PC TechBill SageTV Software 4 10-12-2007 02:12 AM
Question about R5000 with a 2nd SD source. cejota3 Hardware Support 5 08-17-2007 01:06 PM
Upgrade Question jphhughes Hardware Support 8 04-06-2007 09:09 PM
Studio API question lotus298 SageTV Studio 2 12-07-2005 01:01 PM
SageTV Client Beta Version 2.1.7 RC4 Test Question mightyt SageTV Beta Test Software 6 10-14-2004 02:32 PM


All times are GMT -6. The time now is 02:28 AM.


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