12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- /// #pkgName FGUI包名
- /// #panelName UIPanel名字
- /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
- /// 该脚本由模板创建
- /// created by cb 2024
- using FairyGUI;
- using System;
- using XGame.Framework.UI;
- namespace FL.FGUI
- {
- /// <summary>
- /// UI逻辑处理类
- /// </summary>
- /// <typeparam name=""></typeparam>
- public partial class GmToolFieldNameListItemCtrl : UIController<GmToolFieldNameListItemVM>
- {
- private Action<GmFieldParam> _changeValueCallback; // 回调函数
- protected override void OnEnable(object intent)
- {
- AddUIListenres();
- }
- protected override void OnDisable()
- {
- RemoveUIListenres();
- if (_changeValueCallback != null) _changeValueCallback = null;
- }
- #region UI事件
- private void AddUIListenres()
- {
- VM.FieldValueInput.onFocusOut.Add(OnFocusOut);
- }
- private void RemoveUIListenres()
- {
- VM.FieldValueInput.onFocusOut.Remove(OnFocusOut);
- }
- #endregion
- public void OnRefresh(int index, GmToolFieldData data)
- {
- VM.FieldNameLabel.text = data.filedName;
- VM.FieldValueInput.text = string.Empty;
- _changeValueCallback = data.changeValueCallback;
- }
- /// <summary>
- /// 失去焦点事件
- /// </summary>
- /// <param name="context"></param>
- private void OnFocusOut(EventContext context)
- {
- //XGame.Log.Info($"失去焦点事件,此时输入框的内容:{VM.FieldValueInput.text}");
- AlterValue();
- }
- /// <summary>
- /// 修改字段值
- /// </summary>
- private void AlterValue()
- {
- if (_changeValueCallback != null)
- {
- _changeValueCallback(new GmFieldParam()
- {
- fieldName = VM.FieldNameLabel.text,
- fieldValue = VM.FieldValueInput.text
- });
- }
- }
- }
- }
|