Finish Text Enty Field With Enter Key

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

Locked
User avatar
Horst Helfen
Posts: 100
Joined: Thu May 05, 2005 4:11 am
Location: Hamburg, Germany
Contact:

Finish Text Enty Field With Enter Key

Post 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?
Horst Helfen

Programmers don't die, they just GOSUB without RETURN.
User avatar
Gaev
Posts: 3782
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada
Contact:

Re: Finish Text Enty Field With Enter Key

Post 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 singleline 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
User avatar
Horst Helfen
Posts: 100
Joined: Thu May 05, 2005 4:11 am
Location: Hamburg, Germany
Contact:

Re: Finish Text Enty Field With Enter Key

Post by Horst Helfen »

Thank you Gaev for your quick answer. That works fine.
Horst Helfen

Programmers don't die, they just GOSUB without RETURN.
User avatar
virger
Posts: 540
Joined: Mon Sep 18, 2006 12:21 pm
Location: Costa Rica, America Central

Re: Finish Text Enty Field With Enter Key

Post 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
COSTA RICA
PURA VIDA
Locked