Re: EUGrid and trapping lostFocus event
- Posted by Tony Steward <tony.steward at gmail.com> Jun 02, 2005
- 577 views
------=_Part_558_31668755.1117712536573 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline This doesn't really solve the problem because it may not be the main window= receiving focus. It may be a button or another grid. Traping the gotFocus o= f every item would be undesirable On 6/1/05, Phil Russell <guest at rapideuphoria.com> wrote: > > > > posted by: Phil Russell <pg_russell at lineone.net <http://lineone.net>> > > Tony Steward wrote: > > > > Hi Phil or anyone who can help, > > I know EUGrid traps most events its self but I do not see a lost focus > > event. > > If I use win32lib's on lostFocus, it is triggered when the grid looses > > focus but, it is also triggered when I click on a different cell in the > > grid. > > I need to run a procedure when a grid truely looses focus. > > > > -- > > Regards > > Tony Steward > > <a href="http://home.exetel.com.au/steward/"> > http://home.exetel.com.au/steward/</a> > > > > Hi Tony, > > This is difficult to solve cleanly at the moment because EuGrid has a > number of > internal windows which are not registered with win32lib. I have come up= > with a > workaround which involves a) recording whenever the grid gets the focus > and b) checking if any other window subsequently gets the focus. > > Here is an example: > > }}} <eucode> > -- > -- Grid lost-focus sample for Tony Steward > -- > -- Phil Russell May 2005 >=20 > without warning >=20 > include win32lib.ew > include eugrid.ew >=20 > atom void > integer Grid, colEditable, colName, colDOB, colPhone > integer grid_has_focus grid_has_focus=0 >=20 > constant GridData = > { > { 0, "Nobby Wombat", "23-04-66", "01273 772244" }, > { 0, "Benny Bear", "01-05-77", "0181 123456" }, > { 0, "Carl Cat", "22-07-92", "01273 665544" }, > { 0, "Winnie Wallaby", "20-05-54", "0208 6772555" }, > { 0, "Sid Snake", "17-09-01", "01273 998877" }, > { 0, "Fred Frog", "05-12-95", "01273 010101" }, > { 0, "Steve Sheep", "17-09-01", "01273 498857" }, > { 0, "Dennis Dog", "12-09-55", "01273 999999" }, > { 0, "Bjorn Badger", "02-11-88", "09191 224455" }, > { 0, "Pete Platypus", "02-02-77", "0208 1996678" }, > { 0, "Velma Vole", "10-09-43", "01273 121212" }, > { 0, "Eric Bison", "17-12-66", "01273 202020" }, > { 0, "Percy Pig", "23-09-49", "01273 554433" }, > { 0, "Bill Beetle", "13-10-84", "01203 191919" } > } >=20 > --*------------------------------------------------------* > -- Windows > --*------------------------------------------------------* > constant MainWin = create( Window, "EuGrid Demo", 0, 50, 50, 480, 400, = 0 ) > constant Edit1 = create( EditText, "Edit1", MainWin, 10, 325, 50, 20, 0= ) > constant Edit2 = create( EditText, "Edit2", MainWin, 60, 325, 50, 20, 0= ) > --*------------------------------------------------------* > -- Define grid window > --*------------------------------------------------------* > -- Create grid, create parms=(parent, x, y, width, height, show_window) > Grid = EGW_CreateGrid( MainWin, 10, 15, 450, 300, EGW_True ) >=20 > -- Name column > colName = EGW_AddColumn( Grid, "Name", 100, EGW_LAST, EGW_EDIT, 2 ) >=20 > -- Date of Birth column > colDOB = EGW_AddColumn( Grid, "DOB", 50, EGW_LAST, EGW_EDIT, 3 ) > void = EGW_SetColumnProperty( Grid, colDOB, EGW_COL_ALIGN, EGW_RIGHT ) >=20 > -- Phone Number column > colPhone = EGW_AddColumn( Grid, "Phone", 100, EGW_LAST, EGW_EDIT, 4 ) > void = EGW_SetColumnProperty( Grid, colPhone, EGW_COL_ALIGN, EGW_CENTER= ) >=20 > -- Load dataset into grid > void = EGW_LoadData( Grid, GridData, EGW_REPLACE ) >=20 > -- ***Set initial focus to grid > setFocus(Grid) > -- ***Record the fact > grid_has_focus=1 >=20 > --*------------------------------------------------------* > -- Grid message handler > --*------------------------------------------------------* > procedure Grid_onGotFocus (integer self, integer event, sequence params) > grid_has_focus=1 > end procedure > setHandler( Grid, w32HGotFocus, routine_id("Grid_onGotFocus")) > --*------------------------------------------------------* > -- Other windows message handler > --*------------------------------------------------------* > procedure OtherWin_onGotFocus (integer self, integer event, sequence=20 > params) > if grid_has_focus=1 then > grid_has_focus=0 > printf(1, "the grid lost the focus\n", {}) > end if > end procedure >=20 > -- ***Add all other windows on form to handler list > setHandler( {Edit1,Edit2}, w32HGotFocus,=20 > routine_id("OtherWin_onGotFocus")) >=20 > --*------------------------------------------------------* > -- Open main window >=20 > --*------------------------------------------------------*---------------= -------------------------------------------------------------- > WinMain( MainWin, Normal ) > </eucode> {{{ > > Hopefully this will help. The important bits are the two procedures and= > the lines > marked with ***. > > A caveat: it's late here and I've just got back from the pub - treat with= > caution!! > > I will be away for the next week - let me know if you still have a proble= m > and I will have another look when I get back. > > HTH, > > Phil > > > > > -- Regards Tony Steward www.locksdownunder.com <http://www.locksdownunder.com> IF IT IS TO BE IT IS UP TO ME!