コード例 #1
0
 public static void Activate(this TextInput self, bool activate = true)
 {
     self.Also(x =>
     {
         x.CssClass = activate ? "" : "DisabledText";
         if (!self.Data.ContainsKey(TextInputActivationHandler.Key))
         {
             self.Data[TextInputActivationHandler.Key] = new TextInputActivationHandler();
         }
         var handler = (TextInputActivationHandler)self.Data[TextInputActivationHandler.Key];
         x.Focused.ChangedByInput -= handler.FocusedChangedByInput;
         x.UserTextChanged.Event  -= handler.UserTextChanged;
         if (!activate)
         {
             handler.FocusedChangedByInput = () => x.UnFocus();
             x.Focused.ChangedByInput     += handler.FocusedChangedByInput;
             var text = x.Text;
             handler.UserTextChanged  = () => x.Text = text;
             x.UserTextChanged.Event += handler.UserTextChanged;
         }
     });
 }