本文整理汇总了C#中UITextField.Focus方法的典型用法代码示例。如果您正苦于以下问题:C# UITextField.Focus方法的具体用法?C# UITextField.Focus怎么用?C# UITextField.Focus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UITextField
的用法示例。
在下文中一共展示了UITextField.Focus方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
public override void Start()
{
base.Start();
backgroundSprite = "UnlockingPanel2";
isVisible = true;
canFocus = true;
isInteractive = true;
width = 250;
// Title Bar
m_title = AddUIComponent<UITitleBar>();
m_title.title = "Create New Theme";
m_title.iconSprite = "ToolbarIconZoomOutCity";
m_title.isModal = true;
// Name
UILabel name = AddUIComponent<UILabel>();
name.height = 30;
name.text = "Theme name:";
name.relativePosition = new Vector3(5, m_title.height);
m_name = UIUtils.CreateTextField(this);
m_name.width = width - 10;
m_name.height = 30;
m_name.padding = new RectOffset(6, 6, 6, 6);
m_name.relativePosition = new Vector3(5, name.relativePosition.y + name.height + 5);
m_name.Focus();
m_name.eventTextChanged += (c, s) =>
{
m_ok.isEnabled = !s.IsNullOrWhiteSpace() && BuildingThemesManager.instance.GetThemeByName(s) == null;
};
m_name.eventTextSubmitted += (c, s) =>
{
if (m_ok.isEnabled) m_ok.SimulateClick();
};
// Ok
m_ok = UIUtils.CreateButton(this);
m_ok.text = "Create";
m_ok.isEnabled = false;
m_ok.relativePosition = new Vector3(5, m_name.relativePosition.y + m_name.height + 5);
m_ok.eventClick += (c, p) =>
{
UIThemeManager.instance.CreateTheme(m_name.text);
UIView.PopModal();
Hide();
};
// Cancel
m_cancel = UIUtils.CreateButton(this);
m_cancel.text = "Cancel";
m_cancel.relativePosition = new Vector3(width - m_cancel.width - 5, m_ok.relativePosition.y);
m_cancel.eventClick += (c, p) =>
{
UIView.PopModal();
Hide();
};
height = m_cancel.relativePosition.y + m_cancel.height + 5;
relativePosition = new Vector3(Mathf.Floor((GetUIView().fixedWidth - width) / 2), Mathf.Floor((GetUIView().fixedHeight - height) / 2));
}
示例2: Start
public override void Start()
{
base.Start();
backgroundSprite = "UnlockingPanel2";
isVisible = false;
canFocus = true;
isInteractive = true;
width = 350;
// Title Bar
m_title = AddUIComponent<UITitleBar>();
m_title.title = "Clone Building";
m_title.iconSprite = "ToolbarIconZoomOutCity";
m_title.isModal = true;
// Name
UILabel name = AddUIComponent<UILabel>();
name.height = 30;
name.text = "Building name:";
name.relativePosition = new Vector3(5, m_title.height);
m_name = UIUtils.CreateTextField(this);
m_name.width = width - 115;
m_name.height = 30;
m_name.padding = new RectOffset(6, 6, 6, 6);
m_name.relativePosition = new Vector3(5, name.relativePosition.y + name.height + 5);
m_name.Focus();
m_name.eventTextChanged += (c, s) => CheckValidity();
// Level
m_level = UIUtils.CreateDropDown(this);
m_level.width = 100;
m_level.height = 30;
(m_level.triggerButton as UIButton).textPadding = new RectOffset(6, 6, 6, 0);
m_level.relativePosition = new Vector3(m_name.relativePosition.x + m_name.width + 5, m_name.relativePosition.y);
m_level.eventSelectedIndexChanged += (c, i) => CheckValidity();
// Ok
m_ok = UIUtils.CreateButton(this);
m_ok.text = "Clone";
m_ok.isEnabled = false;
m_ok.relativePosition = new Vector3(5, m_name.relativePosition.y + m_name.height + 5);
m_ok.eventClick += (c, p) =>
{
UIThemeManager.instance.CloneBuilding(m_item, m_cloneName, m_selectedLevel);
UIView.PopModal();
Hide();
};
// Cancel
m_cancel = UIUtils.CreateButton(this);
m_cancel.text = "Cancel";
m_cancel.relativePosition = new Vector3(width - m_cancel.width - 5, m_ok.relativePosition.y);
m_cancel.eventClick += (c, p) =>
{
UIView.PopModal();
Hide();
};
height = m_cancel.relativePosition.y + m_cancel.height + 5;
relativePosition = new Vector3(Mathf.Floor((GetUIView().fixedWidth - width) / 2), Mathf.Floor((GetUIView().fixedHeight - height) / 2));
isVisible = true;
}