swat0284 Posted October 2, 2015 Share Posted October 2, 2015 Hello can i get value from CASTORGUI.GUITextfield? i try to do var testTextField = new CASTORGUI.GUITextfield("GUITextfield", {x:20, y:(50) - 20 , w:180, h:300, value: textVal,placeholder: "tu wpisz"}, guisystem,true); var testButton = new CASTORGUI.GUITexture("editButasdsadton", "data/edit.png", {x:5, y: 100 , w:96/2, h:96/2}, guisystem,function() { textVal = testTextField.value;//i add this textVal = textField.value becouse without it return undefinied alert(textVal);});now it return "". Yes i type some text in input box Quote Link to comment Share on other sites More sharing options...
Dad72 Posted October 3, 2015 Share Posted October 3, 2015 You have to forget the callback:var textVal = null;var function_of_return = function() { textVal = testTextField.value; };var testTextField = new CASTORGUI.GUITextfield("GUITextfield", {x:20, y:(50) - 20 , w:180, h:300, value: "textVal", placeholder: "tu wpisz"}, guisystem, function_of_return, true);I think this should work. I will soon add a feature to getValue() simpler. I would do the same on GUITextarea() Quote Link to comment Share on other sites More sharing options...
Dad72 Posted October 3, 2015 Share Posted October 3, 2015 I add the getValue() and setValue(val) functions for GUITextarea and GUITexfield. The doc is up to date too. You can now get the value like this:var testTextField = new CASTORGUI.GUITextfield("GUITextfield", {x:20, y:(50) - 20 , w:180, h:300, value: "textVal", placeholder: "tu wpisz"}, guisystem, null, true);var textVal = testTextField.getValue(); Quote Link to comment Share on other sites More sharing options...
swat0284 Posted October 5, 2015 Author Share Posted October 5, 2015 It still dont work ;/ Quote Link to comment Share on other sites More sharing options...
Dad72 Posted October 5, 2015 Share Posted October 5, 2015 With me, it works with getValue(). If you do not update CastorGUI.min.js file, it will not work Perhaps you can also try to empty caches. Quote Link to comment Share on other sites More sharing options...
swat0284 Posted October 5, 2015 Author Share Posted October 5, 2015 when i add option value: "my text" i get "my text" on get value but when i type stg in textarea i see old my text. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted October 5, 2015 Share Posted October 5, 2015 Ok, I see what you mean. I'll watch it tomorrow. In made you want to recover the value of the textfield onChange. Attention is a GUITextfield <input type='text'> and not a <textarea> use GUITextarea for this. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted October 6, 2015 Share Posted October 6, 2015 it should be fixed now. Quote Link to comment Share on other sites More sharing options...
swat0284 Posted October 7, 2015 Author Share Posted October 7, 2015 it works now. TNK you Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.