- Home /
TextArea not properly updating
So I am stumped, I have
function OnGUI(){
txtIndex = EditorGUILayout.Popup(txtIndex, temp,GUILayout.Width(100));
if(txtIndex != 0){
var sr : StreamReader = new StreamReader(filename);
notepad = sr.ReadToEnd();
sr.Close();
txtIndex = 0;
}
notepad = EditorGUI.TextArea(Rect(0,0,550,600),notepad, GUI.skin.customStyles[0]);
}
At first the TextArea is my String set as "Default", then when I go to the popup and select a file to load it loads the file and as long as I don't make any changes to the text area I can load other files without issue.
Now when I make a change and then switch to a file I know from other code that the file is loaded, but the textarea stays as whatever change I set it to. Now if I click off the window it changes the textarea to the file text, but when I click back on the Window the textarea changes right back to the text I had changed prior to reloading a text file. I just cant wrap my head around it, I dont want to leave the txtIndex to the file I selected as this wouldn't allow for changes to the text if I needed.
I probably have to explain this a little further, but I am tired and been stuck on this for awhile. Thanks in advance.
There's no reason to put "[closed]" in your question titles, especially since they're not really closed. Just mark the answer as accepted. Also don't post comments as answers.
Oh, I saw others I guess done wrong so I thought I should do it. Thanks for correcting me. Not sure where I did the comment as an answer, but ok.
Answer by jonas-echterhoff · Aug 10, 2011 at 12:55 PM
While you are editing a TextArea or TextField, changes to the source string will not be picked up by the text editor. You could try removing Focus from the TextArea when you want to change the text by calling:
GUIUtility.keyboardControl = 0;
GUIUtility.hotControl = 0;
Your Awesome THAN$$anonymous$$ YOU!!!, took a $$anonymous$$ute to get it to work because I have to remember to remove things I try to get to work that don't, lol. I had a bool in there i was only setting to false and couldn't figure out why even what i had before wasn't working.
Your answer
Follow this Question
Related Questions
Regaining system resources? 1 Answer
Question on Update() 1 Answer
Update increment error (2 + 1 = 0?) 1 Answer
Update - Delaying until next frame? 0 Answers
How to refresh my webplayer at runtime 3 Answers