Hello Guys,
I am new to iHD and just started to write some iHD code.
Now I arrived at the first problem:
<div id="main">
<div id="some_other_div_already_with_buttons" style:display="auto">
<!-- here are already some buttons -->
</div>
<div id="surrounding_div" style:display="none">
<button id="button" />
</div>
</div>
Now I want to set the button to visible and set the focus on it:
document.getElementById("surrounding_div").style.display="auto";
document.getElementById("button").state.focused="true";
document.getElementById("button").state.unsetProperty("focused");
The Button gets visible but doesn't get the focus.
Philli

Can't set Focus
vjn
Lars Andreas Ek
I assume you set the Focus with document.getElementById("xyz").state.focused="true";
After this the Focus is locked on this button (afaik similar to using fill="hold" in markup).
You have to put another line below this with
document.getElementById("xyz").state.unsetProperty("focus");
That you can move on with the focus.
MBushell
indersunny
I have a cue like this. Just didn't write it down to keep the code short.
I added the unsetProperty because of earlier experiences where the Focus wasn't moveable to another button after ...state.focused="true".
But I also tried without but it doesn't work too.
I don't know how the painting is done. Could it be possible that the button isn't completely painted (after .style.display="auto") before the state.focused="true" and that's why this doesn't apply to the button
OptikConnex
document.answerButton1.state.focused=
"true";document.answerButton1.state.unsetProperty(
"focused");With these i can click other buttons with mouse and after this i can move with arrow keys, but i need to click and this is bad.
With these (i write focused instead of focus...)
document.getElementById(answerButton1).state.focused=
"true";document.getElementById(answerButton1).state.unsetProperty(
"focused");I get an error that says that answerButton1 is undefined...
MrGenius
djshades2004
Case #2 -- "it" applies to focus. Since focus is a single global thing, if you lock focus on one button then it is locked for all buttons across all application.
If you animate other properties with script (eg, style:backgroundColor) then only that particular property on that particular element is locked (ie, you can still change style:width on that button with markup, and you can change style:backgroundColor on all other elements with markup; you just can't change style:backgroundColor on that button until you call unsetProperty), but focus is different because it's just like the Highlander -- there can be only one.
Also note that if you perform another script animation then you don't have to unset first -- unsetting is just to release it back to markup or the navigation engine (cursor movement).
phestermcs
If I have a text input named 'input1' which is empty
and I use script to change its value
document.input1.state.value = 'preset';
Then this value cannot be changed by any user interaction unless
I do document.input1.unsetProperty('state:value');
But if I do unsetProperty, its value goes to empty again.
So it's impossible to preset user input boxes by script.
Is this true
And what if I use script to focus more than one elements
document.input1.state.focused = 'true';
document.input2.state.focused = 'true';
Now both of them are focused
I think these behavior is not clearly defined in spec.
kevzn
Yes, you need unsetProperty to remove script's control of it and let the default navigation manager handle it again.
In your sample code, you haven't specified things like style:position="absolute" or given your div / button width and height. You need to do that.
WilsonR
I have a problem with the focus. I have a div with buttons that is not displayed at the begining. I display it with the script and i want to set the focus to one of the buttons. The button gets the focus but I can't "move the focus" to the other buttons with the keyboard arrows...
Any idea
PentagonMaster
"it" applies to only that particular button or all the buttons
case 1)
If it applies two only the button whose state:focused was set by script then we might have two buttons focused at the same time
e.g. one set by the script and other by default navigation manager whwn user clicks on some other button.
case 2) If it applies to all the buttons then the focus would be disabled in all the other buttons.
Thanks
Alfredo Di Patti
document.getElementById("button").state.focused="true";
This should set the button's focus attribute to true.
But, this will not change the appearence of the button.
in order to show that the button is focused in terms of "change in button apperance".
you can definie a timing block where u take animate the button when it gets focused
eg
<timing clock="page">
<par>
<cue begin="//button[@id='button' and state:focused()=true()]"
end="//button[@id='BTN01' and state:pointer()=false()]">
<set style:border="8px solid fuchsia"/>
</cue>
</par>
</timing>
I hope this would work.
As an afterthought , you are first setting the button to focus and then unseting it in the next line.
This might not work..even after including the timing part.
umm
HSBF Lewe
I request you to please mention the relavation sections of specification which defines this behaviour :)
Thanks in advance for the trouble :)
sc2003
As I mentioned before, this is cleared up in the 1.01 spec (or the 1.0 spec with supplementals). The next release of iHDSim will work properly for the setting-text-in-a-text-box case. (That is, you set it with script then immediately unset it, but the value remains and can now be modified by the timing engine or by the user).
For the focus example, as I mentioned you don't need to unset if you want to manipulate the value with script -- your two lines of code will leave the input2 text box with the focus, and it will NOT be able to be moved by the timing engine or by the user until you unset it.