Skip to content

Commit c533333

Browse files
committed
*it's possible to edit a line by click once; *auto activate next line after one line inputted.
1 parent 21520fd commit c533333

File tree

6 files changed

+18
-8
lines changed

6 files changed

+18
-8
lines changed
Binary file not shown.
Binary file not shown.
-4 Bytes
Binary file not shown.
175 Bytes
Binary file not shown.

prj/Assets/Plugins/MyCodeEditor/MyCodeEditor.cs

+17-8
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ private void EnsureLastLineEditable()
301301
}
302302
}
303303

304-
private IEnumerator RelayoutProc(bool reserveScrollValue)
304+
private IEnumerator RelayoutProc(bool reserveScrollValue, bool activateLast)
305305
{
306306
yield return new WaitForEndOfFrame();
307307

@@ -362,13 +362,20 @@ private IEnumerator RelayoutProc(bool reserveScrollValue)
362362
{
363363
transLineRoot.localPosition = locPos;
364364
}
365+
366+
// Activates last?
367+
if (activateLast)
368+
EditLine(lines.Last());
365369
}
366370

367-
public void Relayout(bool toBottom = false)
371+
public void Relayout(bool toBottom = false, bool activateLast = false)
368372
{
369373
EnsureLastLineEditable();
370374

371-
StartCoroutine(RelayoutProc(toBottom));
375+
if (codeInput.Shown)
376+
codeInput.Hide();
377+
378+
StartCoroutine(RelayoutProc(toBottom, activateLast));
372379
}
373380

374381
public int Append(string text)
@@ -526,6 +533,11 @@ public void Select(IEnumerable<int> indices)
526533
}
527534
}
528535

536+
private void EditLine(MyCodeLine ln)
537+
{
538+
codeInput.Show(ln);
539+
}
540+
529541
public void ScrollToLine(int index)
530542
{
531543
if (index < 0) index = 0;
@@ -538,14 +550,11 @@ public void ScrollToLine(int index)
538550
public void OnScrollLineColValueChanged(Vector2 val)
539551
{
540552
scrollHeadCol.verticalScrollbar.value = val.y;
541-
542-
if (codeInput.Shown)
543-
codeInput.Hide();
544553
}
545554

546555
private void OnLineClicked(MyCodeLine ln)
547556
{
548-
codeInput.Show(ln);
557+
EditLine(ln);
549558
}
550559

551560
private void OnHeadClicked(MyCodeHead hd)
@@ -569,7 +578,7 @@ public void OnInputEdited()
569578

570579
if (relayout)
571580
{
572-
Relayout(true);
581+
Relayout(true, true);
573582
}
574583
}
575584
}

prj/Assets/Plugins/MyCodeEditor/MyCodeInput.cs

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public void Show(MyCodeLine ln)
5858
FieldInput.Rect().SetSize(ln.Rect().GetSize());
5959
FieldInput.Rect().transform.localPosition = (ln.Rect().transform.localPosition);
6060
FieldInput.text = ln.Text;
61+
FieldInput.ActivateInputField();
6162

6263
ln.gameObject.SetActive(false);
6364

0 commit comments

Comments
 (0)