Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: piere on October 29, 2013, 07:35:40 AM

Title: New line in editor. Possible?
Post by: piere on October 29, 2013, 07:35:40 AM
Hello is it possible to make it so when a user hits the enter key, it will go down to a new line in the text editor field? Thanks

(http://snag.gy/xY6Y1.jpg)
Title: Re: New line in editor. Possible?
Post by: 2.0 on October 29, 2013, 11:22:44 AM
As far as I can see, there is no support of formatting indetifiers in Editor field. So it's possible to try to get around the restriction by inserting spaces at the string's break, or try to find other method. For the detection of the breaking you can try the following code inside the window script.

Code: WME Script
  1. on "Keypress"
  2. {
  3.   if(Keyboard.KeyCode==VK_RETURN)
  4.   {
  5.         var edit = this.GetControl("editor");
  6.         var txt = new String(edit.Text);
  7.         var txt1 = txt.Substring(0,edit.SelEnd-1);
  8.         var txt2 = txt.Substring(edit.SelEnd, txt.Length-1);
  9.         edit.Text = txt1 + " " + txt2;
  10.   }
  11. }
Title: Re: New line in editor. Possible?
Post by: piere on October 29, 2013, 12:34:49 PM
Thanks 2.0, you are always helpful. Is there a way that once the text in the textbox is outside of it, it goes to the next line? Right now of the text is outside of the bounds of the textbox, it just gets cut off. For example, if there is more letters in the text box than the length.
Title: Re: New line in editor. Possible?
Post by: 2.0 on October 31, 2013, 04:01:12 PM
Hi. While I have no specific ideas on how to work around this limitation without changing the source code, except the sketch of the idea :)
Static control have a line feed. And if a duplicate row from the editor control to the static - output similar to the correct one.

Code: WME Script
  1. on "editor"
  2. {
  3.         var edit = this.GetControl("editor");
  4.         var text = this.GetControl("text"); // Static control
  5.         text.Text = edit.Text
  6. }

But if you get rid of the editor control, it ceases to receive and send events. Perhaps the keyboard events should be handled directly in the window script and letter by letter added a in a text string of the static control. And also to manually draw the cursor over it. Other ideas while aren't present.
Title: Re: New line in editor. Possible?
Post by: piere on November 01, 2013, 12:46:25 PM
Hey 2.0,

Thank you for the help. I very much appreciate it. I actually found a way to do this using a different method. I made a password protection note taking app in Wintermute and I will be submitting it to the app store soon  ::rock
Title: Re: New line in editor. Possible?
Post by: 2.0 on November 01, 2013, 05:05:32 PM
It is cool! And what the method consists of, if not a secret?
Title: Re: New line in editor. Possible?
Post by: anarchist on November 01, 2013, 06:02:29 PM
Hey 2.0,

Thank you for the help. I very much appreciate it. I actually found a way to do this using a different method. I made a password protection note taking app in Wintermute and I will be submitting it to the app store soon  ::rock

I have had this issue for a long time, enough time to simply discard the multi-line functionality. I would really appreciate it too if you could show us the method you followed.  :)
Title: Re: New line in editor. Possible?
Post by: piere on November 02, 2013, 07:52:20 AM
Simple. Just add mutiple editors, one underneath the other. When Enter is hit, or the Line.SelEnd is a certain number, it drops down to the next box. I have the graphics in place so it looks like one big box. Let me know if that helps.
Title: Re: New line in editor. Possible?
Post by: 2.0 on November 03, 2013, 11:31:49 AM
Simple. Just add mutiple editors, one underneath the other. When Enter is hit, or the Line.SelEnd is a certain number, it drops down to the next box. I have the graphics in place so it looks like one big box. Let me know if that helps.

Really very elegant and simple solution :)
Title: Re: New line in editor. Possible?
Post by: anarchist on November 03, 2013, 09:02:38 PM
Thanks piagent, your solution looks nice and simple. I will try it asap.