- Home /
Question by
MountDoomTeam · May 10, 2013 at 07:55 PM ·
insert
Insert a String in Gui.TextField text?
Hi , say i have a TextField string that sais:
"a= Mathf.Cos(a)+b;"
And a Gui button called "sin"
If i select Mathf.Cos and press gui button sin, i want it to insert the string: "Mathf.Sin" on the area that is selected/ highlighted by mouse in TextField, so the string becomes:
"a= Mathf.Sin(a)+b;"
whats the best method for it?
Comment
i found this although it is quite difficult to understand:
function OnGUI(){
// be sure to check if your textfield has keyboard focus first - -
var te : TextEditor = GUIUtility.GetStateObject((TextEditor), GUIUtility.keyboardControl);
// the TextEditor class is really very nice - you can control selections, move the cursor and a whole lot more
if (te != null){
print(te.SelectedText);
}
}
Your answer
Follow this Question
Related Questions
How to insert terrain, and other objects? 3 Answers
Insert Semicolon error 1 Answer
insert a semicolon at the end?? 1 Answer
Add edge onto plane? 1 Answer
Array - insert item in the middle 1 Answer