<commit_before>﻿using System;
using System.Collections;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

/// Input field that would properly focus
/// and ignore movement and whatnot while it's focused
[Serializable]
public class InputFieldFocus : InputField
{
	/// <summary>
	/// Button that will cause the field to lose focus
	/// </summary>
	public KeyCode ExitButton = KeyCode.Escape;

//disabling auto focus on enable temporarily because it causes NREs
//	protected override void OnEnable() {
//		base.OnEnable();
//		StartCoroutine( SelectDelayed() );
//	}
	/// Waiting one frame to init
	private IEnumerator SelectDelayed()
	{
		yield return WaitFor.EndOfFrame;
		Select();
	}

	private IEnumerator DelayedEnableInput()
	{
		yield return WaitFor.EndOfFrame;
		EnableInput();
	}

	private void DisableInput()
	{
		UIManager.IsInputFocus = true;
		UIManager.PreventChatInput = true;
	}

	private void EnableInput()
	{
		UIManager.IsInputFocus = false;
		UIManager.PreventChatInput = false;
	}

	protected override void OnDisable()
	{
		base.OnDisable();
		if(gameObject.activeInHierarchy)
			StartCoroutine(DelayedEnableInput());
	}

	public override void OnSelect( BaseEventData eventData )
	{
		base.OnSelect( eventData );
		DisableInput();
	}

	public override void OnPointerClick( PointerEventData eventData )
	{
		base.OnPointerClick( eventData );
		DisableInput();
	}

	public override void OnDeselect( BaseEventData eventData )
	{
		base.OnDeselect( eventData );
		StartCoroutine(DelayedEnableInput());
	}

	public override void OnSubmit( BaseEventData eventData )
	{
		base.OnSubmit( eventData );
		StartCoroutine(DelayedEnableInput());
	}

	private void OnGUI()
	{
		if ( Event.current.keyCode == ExitButton )
		{
			OnDeselect(new BaseEventData( EventSystem.current ));
		}
	}
}<commit_msg>Fix Client breaking NRE when using edit field on Canister GUI #2826<commit_after>﻿using System;
using System.Collections;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

/// Input field that would properly focus
/// and ignore movement and whatnot while it's focused
[Serializable]
public class InputFieldFocus : InputField
{
	/// <summary>
	/// Button that will cause the field to lose focus
	/// </summary>
	public KeyCode ExitButton = KeyCode.Escape;

//disabling auto focus on enable temporarily because it causes NREs
//	protected override void OnEnable() {
//		base.OnEnable();
//		StartCoroutine( SelectDelayed() );
//	}
	/// Waiting one frame to init
	private IEnumerator SelectDelayed()
	{
		yield return WaitFor.EndOfFrame;
		Select();
	}

	private IEnumerator DelayedEnableInput()
	{
		yield return WaitFor.EndOfFrame;
		EnableInput();
	}

	private void DisableInput()
	{
		UIManager.IsInputFocus = true;
		UIManager.PreventChatInput = true;
	}

	private void EnableInput()
	{
		UIManager.IsInputFocus = false;
		UIManager.PreventChatInput = false;
	}

	protected override void OnDisable()
	{
		base.OnDisable();
		if(gameObject.activeInHierarchy)
			StartCoroutine(DelayedEnableInput());
	}

	public override void OnSelect( BaseEventData eventData )
	{
		base.OnSelect( eventData );
		DisableInput();
	}

	public override void OnPointerClick( PointerEventData eventData )
	{
		base.OnPointerClick( eventData );
		DisableInput();
	}

	/// <summary>
	/// This event is called when the input field is deselected.
	/// </summary>
	/// <param name="eventData">Data for the event</param>
	public override void OnDeselect( BaseEventData eventData )
	{
		base.OnDeselect( eventData );
	}

	public override void OnSubmit( BaseEventData eventData )
	{
		base.OnSubmit( eventData );
		StartCoroutine(DelayedEnableInput());
	}

	private void OnGUI()
	{
		if ( Event.current.keyCode == ExitButton )
		{
			OnDeselect(new BaseEventData( EventSystem.current ));
		}
	}
}
{'fraction_non_alphanumeric': 0.10358357311012294, 'fraction_numerical': 0.00104629871828407, 'mean_word_length': 4.174560216508795, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5277409', 'n_tokens_mistral': 1256, 'n_tokens_neox': 1210, 'n_words': 319}