( TextInputForm )

api: FrmGetWindowHandle
api: WinSetWindowBounds
api: FrmSetObjectBounds
api: FrmReturnToForm
api: FrmSetFocus
api: FldGetTextPtr
api: FldGetTextLength
api: FldSetMaxChars
api: FntCharHeight
api: RctSetRectangle
api: FrmPopupForm

needs module: modules
needs Form: gui

module: TextInputForm

0 value x
0 value y
0 value width
0 value TextAddr
0 value TextLen
0 value NotifyEvent

: Go
	TextInputFormID
	FrmPopupForm ;

TextInputFormID Form:

firstUserEvent
constant afterOpenEvent

create Rect 8 allot

e: frmOpenEvent IsEvent e>
	Rect >abs
	x y width FntCharHeight
	RctSetRectangle
	FormPtr FrmGetWindowHandle
	Rect >abs WinSetWindowBounds
	afterOpenEvent
	AddNotifyEvent
	unhandled ;e
e: afterOpenEvent IsEvent e>
	FieldID ObjPtr TextLen
	FldSetMaxChars
	FormPtr FieldID ObjIndex
	2dup
	0 Rect !
	Rect >abs FrmSetObjectBounds
	FrmSetFocus ;e
e: keyDownEvent IsEvent e>
ev. chr 0x0A = e>
	FieldID ObjPtr
	dup FldGetTextPtr >rel
	swap FldGetTextLength
	dup to TextLen TextAddr
	?dup 0= if
		dup 1+ allocate throw
		dup to TextAddr then
	swap move
	TextAddr TextLen + 0 swap c!
	0 FrmReturnToForm
	NotifyEvent AddNotifyEvent ;e
;Form

;module