Re: lost focus
- Posted by gwalters at sc.rr.com Feb 19, 2002
- 517 views
thanks for the example. George Walters 3418 Wilmot Ave. Columbia, SC 29205 803/765-1128(work) 803/771-4700(home) 803/422-1648(cell when on) ----- Original Message ----- From: "Derek Parnell" <ddparnell at bigpond.com> To: "EUforum" <EUforum at topica.com> Subject: Re: lost focus > > ----- Original Message ----- > From: <gwalters at sc.rr.com> > To: "EUforum" <EUforum at topica.com> > Sent: Tuesday, February 19, 2002 5:09 AM > Subject: lost focus > > > > can someone show me how to tell when an editText field looses focus > whether > > it came about from a tab or mouse click or otherwise? i would like to take > > some action based on what caused the lost focus. > > > > Hi George, > here is one way to do it... > > --- > without warning > include win32lib.ew > constant w = createEx(Window,"TEST", 0, 0, 0, 100, 200, 0, 0), > f1 = createEx(EditText, "one", w, 5, 5, 80, 25, 0, 0), > f2 = createEx(EditText, "two", w, 5, 45, 80, 25, 0, 0), > f3 = createEx(EditText, "three", w, 5, 85, 80, 25, 0, 0), > sb = createEx(StatusBar, "", w, 0, 0, 0, 0, 0, 0) > > atom vEvent vEvent = -1 > > procedure eh(integer self, integer event, sequence parms) > atom Msg > Msg = parms[1] > if find(Msg, {WM_KEYDOWN, WM_LBUTTONDOWN, WM_RBUTTONDOWN}) then > vEvent = Msg > end if > end procedure > > procedure lf(integer self, integer event, sequence parms) > sequence msg > > if vEvent = WM_KEYDOWN then > msg = "key" > elsif find(vEvent, {WM_LBUTTONDOWN, WM_RBUTTONDOWN}) then > msg = "btn" > elsif vEvent = 0 then > msg = "other" > elsif vEvent = -1 then > msg = "initial" > else > msg = sprintf("%d?", vEvent) > end if > > setText(sb, sprintf("%s %s ", {getText(self), msg})) > -- Reset so we can trap Alt-TAB etc... > vEvent = 0 > > end procedure > > setHandler({f1,f2,f3}, w32HEvent, routine_id("eh")) > setHandler({f1,f2,f3}, w32HLostFocus, routine_id("lf")) > > WinMain(w, Normal) > ---------- > cheers, > Derek > > > >