Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Showing with 11 additions and 7 deletions.
  1. +11 −7 AutoSelect.cs
View
18 AutoSelect.cs
@@ -65,7 +65,7 @@ public static class GUILayoutAutoSelect {
// Helper/support stuff.
public static class CoreAutoSelect {
// Internal gubbins for auto-select controls.
- private static int lastKeyboardControl = -1;
+ public static string lastFocusedControl = null;
public static void Pre(string name) {
// Each widget needs a unique name so we can differentiate them.
GUI.SetNextControlName(name);
@@ -74,17 +74,21 @@ public static class CoreAutoSelect {
public static void Post(string name) {
// And now, the magic:
// Check to see if keyboard focus has changed on us...
- int kbdCtrlId = GUIUtility.keyboardControl;
- if(kbdCtrlId != lastKeyboardControl) {
+ string focusedControl = GUI.GetNameOfFocusedControl();
+ if(lastFocusedControl != focusedControl) {
// It has! Now, check to see if the focused control is this text area...
- string focusedControl = GUI.GetNameOfFocusedControl();
if(focusedControl == name) {
// It is! Now, get the editor state (spooky voodo!), and tweak it.
- TextEditor t = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), kbdCtrlId);
+ TextEditor t = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);
t.SelectAll();
+
// Update this here or state gets mangled when there's multiple
- // AutoSelectTextArea.
- lastKeyboardControl = kbdCtrlId;
+ // AutoSelectTextArea objects and you switch between them.
+ lastFocusedControl = focusedControl;
+ } else if(focusedControl == "") {
+ // Update this here or switching back and forth between normal TextArea
+ // and AutoSelectTextArea widgets will have problems.
+ lastFocusedControl = focusedControl;
}
}
}

No commit comments for this range

Something went wrong with that request. Please try again.