I created the following text edit with placeholder functionality and want to have a change event bubbled up:
<Panel ux:Class="TextEditWithPlaceHolder" PlaceHolderColor="#999" TextAlignment="BottomLeft" TextFontSize="18" TextValue="" IsPassword="false">
<UserEvent Name="OnChange" />
<float4 ux:Property="TextColor" />
<float4 ux:Property="PlaceHolderColor" />
<float ux:Property="TextFontSize" />
<Alignment ux:Property="TextAlignment" />
<string ux:Property="TextValue" />
<string ux:Property="PlaceHolder" />
<bool ux:Property="IsPassword" />
<JavaScript>
function valueChanged(args){
var UserEvents = require('FuseJS/UserEvents');
UserEvents.raise('OnChange', {
args: args
});
}
module.exports = {
textValueChanged: valueChanged
};
</JavaScript>
<WhileFalse ux:Name="showPlaceHolder">
<Text Value="{Property this.PlaceHolder}" Alignment="{Property this.TextAlignment}" TextColor="{Property this.PlaceHolderColor}" FontSize="{Property this.TextFontSize}" Margin="0,0,0,1" />
</WhileFalse>
<TextEdit ux:Name="txtInput" Value="{Property this.TextValue}" ValueChanged="{textValueChanged}" Alignment="{Property this.TextAlignment}" TextColor="{Property this.TextColor}" IsPassword="{Property this.IsPassword}" FontSize="{Property this.TextFontSize}" Width="100%" Height="100%" >
<WhileContainsText>
<Change showPlaceHolder.Value="true"/>
</WhileContainsText>
</TextEdit>
This class is then used on a page like this:
<Page ux:Class="Login" ux:Name="self" Background="#FFF">
<EnteringAnimation>
</EnteringAnimation>
<ExitingAnimation>
<Change self.Opacity="0" Duration="0.2" Easing="CubicInOut" />
<Change self.IsEnabled="false" />
</ExitingAnimation>
<WhileActive Threshold="0.9">
<BringToFront />
</WhileActive>
<UserEvent Name="successfullyLogin" />
<JavaScript>
var Global = require ('Global');
console.log('Global.language', Global.language.value);
function changed() {
console.log('changed');
}
module.exports = {
user: Global.userId,
password: Global.userPwd,
changed: changed
};
</JavaScript>
<ux:Include File="Styles.ux" />
<ux:Include File="Language.ux" />
<WhileTrue ux:Name="loading">
<Change changeWidth.Value="true" DelayBack="0" />
<Change loadCircle.Value="true" DelayBack="0" />
<Change scaleAndFade.Value="true" Delay="2.5" DelayBack="0" />
<Change showLoggedIn.Value="true" Delay="2.9" />
</WhileTrue>
<WhileTrue ux:Name="changeWidth">
<Change rectNormalScale.Width="60" Duration=".5" DurationBack="0" Easing="CircularInOut" />
</WhileTrue>
<WhileTrue ux:Name="loadCircle">
<Change txtSignIn.Opacity="0" Duration="0.2" DurationBack="0" />
<Change loadingCircle.Opacity="1" Duration="0.3" Delay="0.2" DelayBack="0" DurationBack="0" />
<Spin Target="loadingCircle" Frequency="2" />
<Cycle Target="loadingCircle.LengthAngleDegrees" Low="30" High="300" Frequency="0.7" />
</WhileTrue>
<WhileTrue ux:Name="scaleAndFade">
<Change loadingCirclePanel.Opacity="0" Duration="0.1" />
<Change loadingButton.Opacity="1" Duration="0.01" />
<Change rectNormalScale.Opacity="0" Duration="0.01" />
<Change loginButtonScaling.Factor="1" Delay="0.01" Duration="0.7" DurationBack="0" Easing="ExponentialInOut" />
</WhileTrue>
<WhileTrue ux:Name="showLoggedIn">
<RaiseUserEvent Name="successfullyLogin" />
</WhileTrue>
<Grid ux:Name="loggedOutView" RowData="1.5*,auto,1*" Padding="40,0">
<Rectangle Layer="Background">
<!-- <ImageFill File="Assets/bglogin.png"/> -->
</Rectangle>
<Panel Row="2" Width="150" Height="60">
<Text ux:Name="txtSignIn" Alignment="Center" Value="{Resource labSignIn}" FontSize="22" Font="SemiBold" TextColor="#fff" />
<Panel ux:Name="loadingCirclePanel">
<Circle ux:Name="loadingCircle" Width="70%" Height="70%" Opacity="0" StartAngleDegrees="0" LengthAngleDegrees="90">
<Stroke Width="1" Brush="#fff" />
</Circle>
</Panel>
<Clicked>
<Toggle Target="loading" />
</Clicked>
<Rectangle ux:Name="rectNormalScale" CornerRadius="30" Fill="{Resource clrProductColor}" Width="300" Height="60" />
<Panel ux:Name="loadingButton" Opacity="0" Width="1320" Height="1320" Alignment="Center">
<Circle Fill="{Resource clrProductColor}" />
<Scaling ux:Name="loginButtonScaling" Factor="0.04545" />
</Panel>
</Panel>
<Grid Row="1" Padding="20,10" RowCount="2" Columns="auto,1*" Height="120">
<Image Row="0" Column="0" File="Assets/Images/user.png" Width="20" Height="20" Margin="6,0,20,8" Alignment="BottomLeft" />
<TextEditWithPlaceHolder Row="0" Column="1" Margin="0,0,0,4" TextColor="{Resource clrTextboxForeground}" PlaceHolderColor="{Resource clrTextboxPlaceHolder}" PlaceHolder="Anmeldename" TextFontSize="18" Width="100%" TextAlignment="BottomLeft" Alignment="BottomLeft" TextValue="{user}" />
<Rectangle Row="0" Column="0" Alignment="Bottom" ColumnSpan="2" Height="1" Fill="{Resource clrTextboxBorder}" />
<Image Row="1" Column="0" File="Assets/Images/password.png" Width="20" Height="20" Margin="6,0,20,8" Alignment="BottomLeft" />
<TextEditWithPlaceHolder Row="1" Column="1" Margin="0,0,0,4" TextColor="{Resource clrTextboxForeground}" PlaceHolderColor="{Resource clrTextboxPlaceHolder}" PlaceHolder="Kennwort" IsPassword="true" TextFontSize="18" Width="100%" TextAlignment="BottomLeft" Alignment="BottomLeft" TextValue="{password}" />
<Rectangle Row="1" Column="0" Alignment="Bottom" ColumnSpan="2" Height="1" Fill="{Resource clrTextboxBorder}" />
</Grid>
</Grid>
Everthing works, but the event handler definition in line 26 leeds to the following error:
Preview detected an unhandled exception: System.Exception: Can't call function when sender is unrooted at Fuse.Reactive.EventBinding.OnEvent (System.Object sender, System.EventArgs args) [0x00000] in <filename unknown>:0
at (wrapper delegate-invoke) Uno.UX.ValueChangedHandler`1<string>:invoke_void_object_ValueChangedArgs`1<T> (object,Uno.UX.ValueChangedArgs`1<string>)
at Fuse.Controls.TextControl.OnValueChanged (System.String newString, System.Object origin) [0x00000] in <filename unknown>:0
at Fuse.Controls.TextEdit.OnValueChanged (System.String newString, System.Object origin) [0x00000] in <filename unknown>:0
at Fuse.Controls.TextControl.SetValue (System.String value, System.Object origin) [0x00000] in <filename unknown>:0
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
at Outracks.Simulator.Runtime.TryInvokeExtension.Try (System.Func`1 func) [0x0000d] in /Users/outracks/buildAgent1/work/b939dc4c6ac331f9/Source/Outracks.Simulator.Runtime/Reflection/CompiledTypeReflection.cs:286
at Outracks.Simulator.Runtime.TryInvokeExtension.TryInvoke (System.Reflection.MethodInfo mi, System.Object obj, System.Object[] value) [0x0001b] in /Users/outracks/buildAgent1/work/b939dc4c6ac331f9/Source/Outracks.Simulator.Runtime/Reflection/CompiledTypeReflection.cs:275
at Outracks.Simulator.Runtime.CompiledTypeReflection.CallDynamic (System.Object obj, Outracks.Simulator.Bytecode.TypeMemberName methodName, System.Object[] arguments) [0x00007] in /Users/outracks/buildAgent1/work/b939dc4c6ac331f9/Source/Outracks.Simulator.Runtime/Reflection/CompiledTypeReflection.cs:118
at Outracks.Fuse.Preview.RuntimeObjectPoker.<HookUpReflectionInterface>m__0 (System.Object a, System.String b, System.Object[] c) [0x00000] in /Users/outracks/buildAgent1/work/b939dc4c6ac331f9/Source/Outracks.Fuse.Preview/RuntimeObjectPoker.cs:27
at Outracks.Simulator.Reflection.DelegateReflection.Outracks.Simulator.Runtime.IReflection.CallDynamic (System.Object instance, Outracks.Simulator.Bytecode.TypeMemberName methodName, System.Object[] arguments) [0x00000] in <filename unknown>:0
at Outracks.Simulator.Runtime.ScopeClosure.Evaluate (Outracks.Simulator.Bytecode.CallDynamicMethod m) [0x00000] in <filename unknown>:0
at Outracks.Simulator.Bytecode.Expression.Match[Object] (System.Func`2 a1, System.Func`2 a2, System.Func`2 a3, System.Func`2 a4, System.Func`2 a5, System.Func`2 a6, System.Func`2 a7, System.Func`2 a8, System.Func`2 a9, System.Func`2 a10, System.Func`2 a11, System.Func`2 a12, System.Func`2 a13, System.Func`2 a15, System.Func`2 a16) [0x00000] in <filename unknown>:0
at Outracks.Simulator.Runtime.ScopeClosure.Evaluate (Outracks.Simulator.Bytecode.Expression expression) [0x00000] in <filename unknown>:0
at Outracks.Simulator.Runtime.ScopeClosure.Execute (IEnumerable`1 statements) [0x00000] in <filename unknown>:0
at Outracks.Simulator.Runtime.ScopeClosure.Execute (Outracks.Simulator.Bytecode.Lambda lambda, System.Object[] arguments) [0x00000] in <filename unknown>:0
at Outracks.Simulator.Runtime.LambdaClosure.Func (System.Object a1, System.Object a2) [0x00000] in <filename unknown>:0
at Outracks.Simulator.Runti