Skip to content

Commit

Permalink
Merge pull request #160 from kou-yeung/feature/#159
Browse files Browse the repository at this point in the history
add SyncText() to sync from inputfield.
  • Loading branch information
kou-yeung authored May 29, 2024
2 parents ee18964 + 5c773e1 commit fd6a006
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions Assets/WebGLSupport/WebGLInput/WebGLInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,25 @@ public void OnSelect()
WebGLWindow.OnBlurEvent += OnWindowBlur;
}

void OnWindowBlur()
/// <summary>
/// sync text from inputfield
/// </summary>
/// <param name="cursorIndex"></param>
public void SyncText(int? cursorIndex = null)
{
if (!instances.ContainsKey(id)) return;

var instance = instances[id];

WebGLInputPlugin.WebGLInputText(id, instance.input.text);

if (cursorIndex.HasValue)
{
WebGLInputPlugin.WebGLInputSetSelectionRange(id, cursorIndex.Value, cursorIndex.Value);
}
}

private void OnWindowBlur()
{
blurBlock = true;
}
Expand Down Expand Up @@ -420,7 +438,7 @@ public int CompareTo(WebGLInput other)
return res;
}

public void CheckOutFocus()
private void CheckOutFocus()
{
if (!Application.isMobilePlatform) return;
if (!instances.ContainsKey(id)) return;
Expand Down

0 comments on commit fd6a006

Please sign in to comment.