[futurebasic] Re: [FB] Re: Button/Return/EFs

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : July 2002 : Group Archive : Group : All Groups

From: Martin Fitzgibbons <rush@...>
Date: Thu, 18 Jul 2002 23:43:18 +1000
Ken

Many thanks for the 2 examples. What does the @ indicate in the @ fn
CaptureEFReturn?

Martin

> Martin asked:
>
> >If you have an edit field with the cursor in it but also want to close
> >the window after typing in the ef by pressing the Return key, where do
> >you trap that? Do you have to set up a filter keys fn or is there an
> >event?
> >
> >Martin
>
> Martin,
>
> You can capture the Return either way, but beware of the danger that
> your user could accidentally hit the return key while typing and
> trigger an unwanted event. Also remember that if you trap the Return
> (chr$(13)), your edit field cannot accept returns.
>
> Using an edit field styled with _framedNoCR, you can trap the event
> in the dialog handler with _efReturn like this:
>
> local fn DoReturn
> //Capture your edit field stuff here before closing window
> window close 1
> beep: delay 500: beep// To show we're done
> gFBQuit = _zTrue
> end fn
>
> local fn DoDialog
> dim as long evnt, id
>
> evnt = dialog(0)
> id = dialog(evnt)
>
> select case( evnt )
> case _efReturn// Capture carriage return in _framedNoCR edit field
> select( id )
> case 2 : fn DoReturn
> end select
>
> end select
>
> end fn
>
> on dialog fn DoDialog
>
> dim as str31 efStr
> window 1,"",(0, 0)-(200, 90)
> efStr = "Type something then hit Return:
> edit field 1, efStr, (10, 10)-(190, 30), _statNoframed
> edit field 2,    "", (10, 35)-(190, 70), _framedNoCR
>
> do
> handleevents
> until gFBQuit
> end
>
> Using the new edit field filter, you can trap the Return like this:
>
> local fn CaptureEFReturn
> dim as str15 k
>
> k = TEKEY$
> long if asc( k ) = 13// Capture carriage return
> TEKEY$ = k
> //Capture your edit field stuff here before closing window
> window close 1
> beep: delay 500: beep // To show we're done
> gFBQuit = _zTrue
> xelse
> TEKEY$ = k// Let other keys through
> END IF
>
> end fn
>
> local fn BuildWindow
> dim as pointer @ filterFN
> dim as str31     efStr
>
> window 1,"",(0, 0)-(200, 90)
> efStr = "Type something then hit Return:
> edit field 1, efStr, (10, 10)-(190, 30), _statNoframed
> filterFN = @ fn CaptureEFReturn
> edit field 2,    "", (10, 35)-(190, 70), _framed,,filterFN
> end fn
>
> fn BuildWindow
>
> do
> handleevents
> until gFBQuit
> end
>
> I hope this proves helpful.
>
> Ken
>
> p.s. Please watch for lost underscores on the Associate server.
>
> --
> To unsubscribe, send ANY message to <futurebasic-unsubscribe@...>