Solved Is it possible to have a default focus control based on a condition?
#1
Say if a window property is true then the default focus on this control or if another window property is true then the default focus on another control.

I have <defaultcontrol>22</defaultcontrol> in the window xml file and it works great if the mouse takes away focus but that control is not always visible and I want the control to default to another control that is visible when the default control that is in the window xml file is not available. Thanks.
Reply
#2
Try using <onload condition="YOUR_CONDITION">SetFocus(ID)</onload>.
Reply
#3
(2023-12-05, 20:55)Hitcher Wrote: Try using <onload condition="YOUR_CONDITION">SetFocus(ID)</onload>.

Thanks for replying. Let me ask though, wouldn't that only work for when the window first loads? What happens is I have a panel list that fills with data when the window first loads and then another panel list that fills with different data in the same window at the same coordinates and the first panel gets hidden when the second panel list loads and fills. I have the default focus set to the first panel and if the mouse gets bumped and the control loses focus I just have to press up or left or right on the remote and the control regains focus. My problem is that if the second panel is visible which hides the first panel list and then the mouse gets bumped or something and I lose focus while the second panel list is visible I have no way to regain focus with the remote on the second panel list because the default control is the first panel list. I have to keep having to grab the mouse and focus somewhere on the second visible panel list to again regain focus. I was hoping somehow there was a way to set a condition that sets the default focus to the panel list that is visible at the time.
Reply
#4
I kind of just hacked it and set a hidden offscreen button as the default control with onup conditions on the hidden button to focus on the panel list visible. I just have to press up twice. I can live with that I suppose. Not pretty but it seems to work. I'll mark this thread as solved if I don't get any replies soon with a proper solution.
Reply
#5
(2023-12-05, 22:50)woodside Wrote: I kind of just hacked it and set a hidden offscreen button as the default control with onup conditions on the hidden button to focus on the panel list visible. I just have to press up twice. I can live with that I suppose. Not pretty but it seems to work. I'll mark this thread as solved if I don't get any replies soon with a proper solution.

Why not use onfocus on your hidden button? And then conditionals that way:

xml:

<control type="button" id="DEFAULT_ID">
<onfocus condition="CONDITION_ONE">SetFocus(1234)</onfocus>
<onfocus condition="CONDITION_TWO">SetFocus(5678)</onfocus>
</control>


Also probably not useful here since the item count of the panel will only be known after the window loads but if you do know the condition at load time you can use includes to set default control conditionally
xml:

<!-- In an includes file of some type -->
<include name="DefaultControl">
<param name="always">false</param>
<definition>
<defaultcontrol always="$PARAM[always]">$PARAM[id]</defaultcontrol>
</definition>
</include>

<!-- In your <window> tags before <controls> -->
<include content="DefaultControl" condition="CONDITION_ONE">
<param name="id">ID_ONE</param>
<param name="always">true</param>
</include>

<include content="DefaultControl" condition="CONDITION_TWO">
<param name="id">ID_TWO</param>
<param name="always">true</param>
</include>
Arctic Fuse - Alpha now available. Support me on Ko-fi.
Reply
#6
(2023-12-06, 07:55)jurialmunkey Wrote:
(2023-12-05, 22:50)woodside Wrote: I kind of just hacked it and set a hidden offscreen button as the default control with onup conditions on the hidden button to focus on the panel list visible. I just have to press up twice. I can live with that I suppose. Not pretty but it seems to work. I'll mark this thread as solved if I don't get any replies soon with a proper solution.

Why not use onfocus on your hidden button? And then conditionals that way:

xml:

<control type="button" id="DEFAULT_ID">
<onfocus condition="CONDITION_ONE">SetFocus(1234)</onfocus>
<onfocus condition="CONDITION_TWO">SetFocus(5678)</onfocus>
</control>

Ahhhh... onfocus completely slipped my mind. That was the ticket. Thanks.
Reply

Logout Mark Read Team Forum Stats Members Help
Is it possible to have a default focus control based on a condition?0