| Author |
Message |
smarl
Joined: 17 Jan 2006 Posts: 2
|
| Posted: Tue Jan 17, 2006 - 9:21 am Post subject: Keyboard focus |
|
|
I am building a widget that accepts keyboard input, and more to the point, remote control input. The only problem I'm having is that if the widget loses focus, I can't figure out a way to automatically gain keyboard focus back.
I have assigned a function to widget.onshow that brings the widget to the foreground using window.focus(). I have tried focus() on body and other elements in the "page", but they silently fail, leaving the widget in a braindead state.
So, to sum up my goal... I want my widget, every time dashboard is invoked, to come to the foregound and gain keyboard focus, so that the widget receives keyboard events, without having to touch the mouse.
Any thoughts? |
|
| |
|
| |
SpiralOcean
Joined: 16 Jul 2006 Posts: 5
|
| Posted: Mon Feb 05, 2007 - 11:53 pm Post subject: |
|
|
Did you figure this out? I'm looking for the same thing.
I guess one of the issues with this is what if there are two widgets that are requesting focus. But that can be solved another time...  |
|
| |
|
| |
smarl
Joined: 17 Jan 2006 Posts: 2
|
| Posted: Tue Feb 06, 2007 - 11:37 am Post subject: |
|
|
No. I've had no luck. The machine is essentially headless except for the remote control, but if that widget loses focus, I have to VNC in to the machine to click it before I can use it with the remote.
Here's what I'm working on, in case you're interested:
http://gumundertheseat.sourceforge.net/ |
|
| |
|
| |
SpiralOcean
Joined: 16 Jul 2006 Posts: 5
|
| Posted: Tue Feb 06, 2007 - 9:28 pm Post subject: |
|
|
Here's an idea.. work with the window.widget object. Add this code to javascript
if (window.widget)
{
widget.onhide = onhide;
widget.onshow = onshow;
}
The onshow is a function:
onshow(){
//some javascript to add focus to the widget
}
When the dashboard is made visible, the onshow function will run inside your widget.
All you have to do is make one of the javascript activate the widget... Maybe an object or a control or even clicking a fake button would probably do it.
Let me know if this helps. |
|
| |
|
| |
islayermarc

Joined: 07 Dec 2005 Posts: 57 Location: Melbourne
|
| Posted: Mon Feb 26, 2007 - 9:29 am Post subject: |
|
|
Brilliant idea for a widget.
Let me know if you need a hand with some graphics. _________________ Over 5.5 million widget and application downloads... and counting. |
|
| |
|
| |