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-20-2007, 04:01 PM
MeInMaui's Avatar
MeInMaui MeInMaui is offline
SageTVaholic
 
Join Date: Feb 2005
Location: Maui. HI
Posts: 4,203
Need Help with Detecting Focus Loss within Panel

Hi guys,

I hope someone can help me.

I have a number of item widgets (buttons) within a panel widget. I would like to perform actions on panel in the event that

1.) Any widget with the panel gains focus
2.) Focus is lost for all widgets in the panel (e.i. focus has shifted outside of the panel)

The first case is easy and is working without problems. The second case is giving me fits. The problem is that when focus shifts from one item widget to the next within the panel, there is a brief window when neither have focus. This causes my attempts to detect loss of focus within the panel to have intermittent false-positives. This is causing very erratic behavior.

It would be nice if the FocusGained and FocusLost hooks could be applied to panel widgets such that FocusGained is triggered if any focusable widget within the panel gains focus and FocusLost is triggered if all focusable widgets within the panel have lost focus.

In the absence of this, are there any ideas on how I might reliably detect when focus is no longer present in any of the elements within a panel?

Thanks.

Aloha,
Mike
__________________
"Everything doesn't exist. I'm thirsty." ...later... "No, it's real!!! I'm full."
- Nikolaus (4yrs old)

Last edited by MeInMaui; 02-20-2007 at 04:03 PM.
Reply With Quote
  #2  
Old 02-20-2007, 04:27 PM
Opus4's Avatar
Opus4 Opus4 is offline
Administrator
 
Join Date: Sep 2003
Location: NJ
Posts: 19,624
Just a quick comment that might show I haven't thought about it long...

The easiest way is to have the FocusGained hook used on widgets outside the panel. But, it sounds like that isn't an option, unless you have something covering the rest of the screen that you can check for focus.

If you say there is a short delay when focus is lost before focus is gained on another element, perhaps it could work to use a delay in the FocusLost hook before seeing what has focus now. You could probably check GetFocusContext after the FocusLost delay too.

- 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-20-2007, 05:45 PM
MeInMaui's Avatar
MeInMaui MeInMaui is offline
SageTVaholic
 
Join Date: Feb 2005
Location: Maui. HI
Posts: 4,203
Thanks Andy,

I thought of the same thing yesterday. Unfortunately this requires hooks in every focusable object to start new threads and run short timers. I couldn't get it to work. But to be honest, I didn't try very hard because the solution felt inelegant and unsatisfying, especially when dealing with many objects. If this turns out to be to only viable approach, I'll try it again. Thanks again for your help.

Aloha,
Mike
__________________
"Everything doesn't exist. I'm thirsty." ...later... "No, it's real!!! I'm full."
- Nikolaus (4yrs old)
Reply With Quote
  #4  
Old 02-20-2007, 06:04 PM
Opus4's Avatar
Opus4 Opus4 is offline
Administrator
 
Join Date: Sep 2003
Location: NJ
Posts: 19,624
You would need a FocusLost hook for each item in the panel, but they could all be references to the same code. The timer part is pretty easy -- just call Wait(a little while) & then continue your check to see if anything in the panel still has focus. Is that what you tried? This method would use a variable local to the overall panel that items could modify via FocusGained, or GetFocusContext() could be used to see if some variable defined under the panel exists & has your value.

Actually, you might be able to just use GetFocusContext() on its own to update some invisible UI area & have its child UI widget chain initiate the settings that would tell the panel that nothing in it has focus -- it could set a status variable & then call RefreshArea() for your panel, whose LayoutStarted hook or whatever could deal with focus being gone. Not sure if that is really the best thing to do, though. Maybe someone else will have a better idea...

- 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 02-20-2007, 06:06 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
Putting a hook on every item in your panel shouldn't be too onerous if you use themes to abstract the common code.

On the other hand it seems like there ought to be a way to solve this with a single thread forked off from AfterMenuLoad or some similar point. This thread would wake up every 100 ms (say) and check to see who has the focus. If the focus is outside the panel twice in a row, fire off your "panel lost focus" code.
__________________
-- Greg
Reply With Quote
  #6  
Old 02-20-2007, 06:22 PM
MeInMaui's Avatar
MeInMaui MeInMaui is offline
SageTVaholic
 
Join Date: Feb 2005
Location: Maui. HI
Posts: 4,203
Thanks for the suggestions, guys. I'll try playing with these ideas and see what happens.

Aloha,
Mike
__________________
"Everything doesn't exist. I'm thirsty." ...later... "No, it's real!!! I'm full."
- Nikolaus (4yrs old)
Reply With Quote
  #7  
Old 02-23-2007, 02:55 PM
MeInMaui's Avatar
MeInMaui MeInMaui is offline
SageTVaholic
 
Join Date: Feb 2005
Location: Maui. HI
Posts: 4,203
So I got this working fairly well, but now I have another issue that has cropped up:

I'd like to place my toolbar in the menu theme that is already used by all of the menus in SageMC, so that the toolbar is always available. My problem is that when I do this, the toolbar always ends up being drawn beneath other UI elements. I don't see any way to force the toolbar to always be on top. It seems the only option I have is to place a reference to the toolbar in every menu and this poses difficulties whenever new screens are added as well as just being a general PITA to set up in an import.

Is there any additional control to the display order of UI elements besides the order they are listed in the widget chain? How do elements in a theme actually fit into the heirarchy? It seems that widgets contained in a theme are always drawn first.

Thanks for listening to yet another ramble.

Aloha,
Mike
__________________
"Everything doesn't exist. I'm thirsty." ...later... "No, it's real!!! I'm full."
- Nikolaus (4yrs old)
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
How to get SageTV to release focus to NVDVD for remote IncredibleHat SageTV Software 4 07-06-2006 07:47 AM
Problem with maldude stv mouse focus nerys SageTV Customizations 0 03-15-2006 09:41 PM
Sage not having focus out of standby? valnar SageTV Software 5 01-26-2006 02:29 AM
Focus Problems rmbu SageTV Software 2 01-02-2006 03:34 PM
Cannot Gain Focus w/Haup. 43btn Remote Beaker Hardware Support 4 11-26-2005 03:14 AM


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.