Closed roidy closed 2 years ago
Nope, wasn't designed for expressions to use the parent option. I honestly didn't even think of this type of approach at all.
Happy to consider adding something like this but I think it is likely to be pretty bad performance wise to have so many control.hasfocus() conditions.
Trying to understand the type of scenario where this wouldn't be better handled with includes/params
e.g. doing $EXP[showinfoupdate_$PARAM[id]]
instead.
Nope, wasn't designed for expressions to use the parent option. I honestly didn't even think of this type of approach at all.
That's what I figured. No problem, it's a single expression that's easy to write by hand.
Happy to consider adding something like this but I think it is likely to be pretty bad performance wise to have so many control.hasfocus() conditions.
No, that's ok, as I said it's a single use case and not worth changing the script for, I just didn't know if that was the expected behaviour of the script.
As for performance that's true for any of these generated variables, take for instance your own 'Defs_PercentPlayed_Progress'
Worst case scenario you're doing 100 Integer.IsEqual comparisons. I know most of the time the variable will resolve well before the 100th while my expression always has to evaluate all of the comparisons, but it's only 5 Control.HasFocus comparisons so I'm not too concerned with the performance. Now if I was doing 100 every time then I'd worried :D
Trying to understand the type of scenario where this wouldn't be better handled with includes/params e.g. doing
$EXP[showinfoupdate_$PARAM[id]]
instead.
I've got a unique situation where I've got an information panel that's separate from my Widgets and thus has no access to the Widgets control 'id' but I need to change it's visibility based on weather the Widget is updating and already has content. I can't think of any other solution.
Worst case scenario you're doing 100 Integer.IsEqual comparisons. I know most of the time the variable will resolve well before the 100th while my expression always has to evaluate all of the comparisons, but it's only 5 Control.HasFocus comparisons so I'm not too concerned with the performance. Now if I was doing 100 every time then I'd worried :D
Yeah I hear you. I really wish that var didn't need to exist. However, in general IsEqual should be relatively fast because it is just checking that int == int which is about the fastest comparison operation possible.
It's more that I find all the Control.HasFocus()
and Control.IsVisible()
type conditions to be a bit performance hungry so generally I try to limit their usage. I'm not sure what goes on with Control.HasFocus() as I would expect it to simply check that system current control ID matches but the performance hits feels like a lot more than that is going on (it's not a massive hit to performance but I found when I used a lot of them in the past I would start to notice it - also possibly placebo, or very situationally specific )
But yeah, only 5 is going to be fine either way. I thought it was more you using it as an example for what would be a much bigger expression overall.
I've got a unique situation where I've got an information panel that's separate from my Widgets and thus has no access to the Widgets control 'id' but I need to change it's visibility based on weather the Widget is updating and already has content. I can't think of any other solution.
Why can't you just use Container.IsUpdating
and Container.NumItems
without any ID? Or is this in a separate custom dialog?
If you only need it visible for specific containers then you can set a window property
EDIT: Never mind me. I forgot that Container.NumItems only works without an ID in the MyNav windows.
Why can't you just use
Container.IsUpdating
andContainer.NumItems
without any ID? Or is this in a separate custom dialog?EDIT: Never mind me. I forgot that Container.NumItems only works without an ID in the MyNav windows.
Yep, as you said Container.NumItems without an id only works in MyNav windows. A crude alternative to
Integer.IsEqual(Container.NumItems,0) is String.IsEmpty(ListItem.Label) and just hope every item has a label, not good :(
If you only need it visible for specific containers then you can set a window property and clear it for those containers. That way you're only checking one condition rather than five.
Yep, that was my first idea, however I couldn't get it to work.
In my Widgets focuseditem I had a hidden button with an onfocus to set a Window property to the current control id
<onfocus>SetProperty(WidgetID,$PARAM[id],home)</onfocus>
That way I'd have the control id of the widget, however on initial load when the widget is empty there's no focuseditem to set the property.
Edit:- Actually String.IsEmpty(ListItem.UniqueID()) should work as that should always have a value if there's an item.
Using the following expression template with a parent:-
<expression name="showInfoUpdate" containers="9101...9105" parent="Control.HasFocus({id})"> [Container({id}).IsUpdating + Integer.IsEqual(Container({id}).NumItems,0)] </expression>
I get this:-
Clearly not correct as it creates a variable that references variables.
I would expect the resultant parent expression to be:-
Is this a bug or was the script never designed to create parents for expressions?