Page 1 of 1

How to make multi-line text entry box ENTER

PostPosted: Wed Aug 21, 2013 7:01 pm
by schmutly
Hello gang.
When i type in a multiline text entry box i want to be able to type a few lines,
hit enter and it THEN send text to an action in another,say button.
If i setup a text box with no mutiline selected and have another button
setup with the shortcut key ENTER..then when i hit enter in the text box
the button clicks down, but i cant simulate this with a mutliline as when
you hit ENTER in a mutliline it goes to next line, fair enough..i want to
override this as its a pain after typing to move mouse to button to click.
Thanks for your help,
Robbie

Re: How to make multi-line text entry box ENTER

PostPosted: Thu Aug 22, 2013 7:43 am
by dpayer
On the Mouse Enter section of the Actions screen, start a timer @10 Milliseconds.

Search the string you are creating in the multiline text object for a carriage return [#13]. If found, cause an action to do what you want.

David P.

Re: How to make multi-line text entry box ENTER

PostPosted: Thu Aug 22, 2013 5:27 pm
by Gaev
schmutly:

Whenever the user presses the "Enter" key, the variable associated with the TextEntry box will store [#13][#10] as its value.

So you can achieve your objective by placing this code in the TextEntry object's Text Change event section ...
Code: Select all
SearchStr "[#13][#10]" "[TextEntry17]" "[EnterKeyPos]" ""
If "[EnterKeyPos]" ">" "0"
    StrReplace "[TextEntry17]" "[#13][#10]" "" "[TextEntry17]" ""
    ... do Enter key processing here
    AlertBox "Info" "Enter Key was pressed"
EndIf

Note that if the user were to paste (from the Clipboard) some text containing multiple lines, the end result may not be desireable.

Re: How to make multi-line text entry box ENTER

PostPosted: Thu Aug 22, 2013 6:32 pm
by schmutly
Thanks guys :)
Ill try both of these and report back.
Cheers,
Robbie

EDIT:
Ok, that works great Gaev, thanks ;P
Thanks David, looks like you both were
on the same page too lol, thanks again.

Re: How to make multi-line text entry box ENTER

PostPosted: Tue Jun 24, 2014 11:34 pm
by schmutly
Gaev wrote:schmutly:

Whenever the user presses the "Enter" key, the variable associated with the TextEntry box will store [#13][#10] as its value.

So you can achieve your objective by placing this code in the TextEntry object's Text Change event section ...
Code: Select all
SearchStr "[#13][#10]" "[TextEntry17]" "[EnterKeyPos]" ""
If "[EnterKeyPos]" ">" "0"
    StrReplace "[TextEntry17]" "[#13][#10]" "" "[TextEntry17]" ""
    ... do Enter key processing here
    AlertBox "Info" "Enter Key was pressed"
EndIf



May i ask why it doesn't seem to work if i use Single line instead of multiline? So, how can i achieve this with the
single line simply ?
Thanks,
Rob
PS: I could just turn on the "shortcut" for ENTER but i have several single line boxes and only allowed one at a time it seems ?!

Re: How to make multi-line text entry box ENTER

PostPosted: Wed Jun 25, 2014 7:52 am
by Gaev
schmutly:
May i ask why it doesn't seem to work if i use Single line instead of multiline?
Because a SingleLine Text widget does not accept the Enter key ... so you do not see the [#13][#10] code for it in the associated data variable.

So, how can i achieve this with the single line simply ?
You could use a MultiLine Text widget ... only adjust its height to make it appear to the user like it is a SingleLine Text widget ... and use the TextChange event section to remove the [#13][#10].

PS: I could just turn on the "shortcut" for ENTER but i have several single line boxes and only allowed one at a time it seems ?!
If you have something against using MultiLine Text widgets ...

a) In the Gain Focus event sections of each of the SingleLine Text widgets ...
Code: Select all
SetVar "[CurrentSingleLineTextWidget]" "[self]"


b) In the Left Click event section of the (hidden) Button with the shortcut key of ENTER ...
Code: Select all
... take actions depending on value of variable [CurrentSingleLineTextWidget]
If "[CurrentSingleLineTextWidget]" "=" "ABCD"
   GoSub "EnterInABCD"
EndIf
If "[CurrentSingleLineTextWidget]" "=" "WXYZ"
   GoSub "EnterInWXYZ"
EndIf
... etc. etc.
... clear the variable
SetVar "[CurrentSingleLineTextWidget]" ""

Re: How to make multi-line text entry box ENTER

PostPosted: Wed Jun 25, 2014 8:11 am
by virger
From Costa Rica
In Wordl Cup

Maybe this can help you
~~~~~~~~~~~~~~~~~~~~
.. Make a ListBox
.. ListItems == [vTx]

.. Make a TexEntry with variable == [vTx]
.. This way you can take any line
..
.. or Add This Action in TextEntry
.strlen "[vTx]" "[Len]"
.substr "[vTx]" "[Len]" "1" "[Chr]"
.if "[Chr]" "=" "[#10]"
. deletearray "[Lines]" "All"
. strparse "[vTx]" "[#13][#10]" "[Lines]" "[NumLines]"
.endif

~~~~~~~~~~~~~~~~~~~
Pura Vida

Re: How to make multi-line text entry box ENTER

PostPosted: Wed Jun 25, 2014 4:52 pm
by schmutly
Thanks Gaev I'll give that a go.
Thanks also virger i'll have a look at that too.
Thanks guys,
Rob