Page 1 of 1

Finish Text Enty Field With Enter Key

PostPosted: Tue Jul 11, 2017 4:31 am
by Horst Helfen
Hello,

I have a TextEntry field and want to finish the entry with ENTER. How can I achieve that my actions begin to work after pressing the ENTER key?

Re: Finish Text Enty Field With Enter Key

PostPosted: Tue Jul 11, 2017 5:14 am
by Gaev
Horst Helfen:

If you define the style of your TextEntry box as a Multiline (no Scroll bars, no Word wrap) ... and make its height just enough to show one line of text ... in other words, make it look (to the user) like a [i]singleline[i] box ... then you can use code like this in the Text Change event section ...
Code: Select all
SearchStr "[#13][#10]" "[TextEntry1]" "[EnterKeyPos]" ""
If "[EnterKeyPos]" ">" "0"
    StrReplace "[TextEntry1]" "[#13][#10]" "" "[TextEntry1]" ""
    ... do Enter key processing here
    AlertBox "Info" "Enter Key was pressed"
EndIf

Re: Finish Text Enty Field With Enter Key

PostPosted: Tue Jul 11, 2017 5:58 am
by Horst Helfen
Thank you Gaev for your quick answer. That works fine.

Re: Finish Text Enty Field With Enter Key

PostPosted: Tue Jul 11, 2017 8:16 am
by virger
Tray this

Code: Select all
{NeoBook 5 Objects}
NeoBookVer=5,80
ObjectType=9
Name=TexEnt
X=34
Y=73
W=283
H=133
Anchor=0
VarName=[Tx]
Align=1
EditMultiLine=Yes
EditLen=0
ObjAction=GetObjectInfo "TexEnt" "CursorPosition" "[ps]"¶substr "[tx]" "[ps]-1" "1" "[ch]"¶if  "[ch]" "=" "[#10]"¶    alertbox "" "enter.."¶endif
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=7