![]() |
|
|||||||
| 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. |
![]() |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
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! |
|
#2
|
||||
|
||||
|
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. |
|
#3
|
||||
|
||||
|
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? |
|
#4
|
||||
|
||||
|
Quote:
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:
Quote:
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. |
|
#5
|
||||
|
||||
|
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.
__________________
-- Greg |
|
#6
|
||||
|
||||
|
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 |
|
#7
|
||||
|
||||
|
You just have to add a line to the properties file and you should be good to go.
Quote:
Quote:
|
|
#8
|
||||
|
||||
|
Ah thanks EP, that did it!
|
|
#9
|
||||
|
||||
|
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. |
|
#10
|
||||
|
||||
|
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 |
|
#11
|
||||
|
||||
|
Quote:
![]() 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... |
|
#12
|
||||
|
||||
|
Quote:
Thanks for the additional info. Every little bit helps |
|
#13
|
||||
|
||||
|
Quote:
__________________
-- Greg |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|
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 |