1. EUGrid and trapping lostFocus event

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
http://home.exetel.com.au/steward/

new topic     » topic index » view message » categorize

2. EUGrid and trapping lostFocus event

------=_Part_662_5296661.1117621115795
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Content-Disposition: inline

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
http://home.exetel.com.au/steward/

------=_Part_662_5296661.1117621115795
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Content-Disposition: inline

Hi Phil or anyone who can help,<br>
I know EUGrid traps most events its self but I do not see a lost focus
event.<br>
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.<br>I need to run a procedure when a grid truely looses focus.<br><br>
-- <br>Regards<br>Tony Steward<br><a
href="http://home.exetel.com.au/steward/">http://home.exetel.com.au/steward/</a><br>
<br>


------=_Part_662_5296661.1117621115795--

new topic     » goto parent     » topic index » view message » categorize

3. Re: EUGrid and trapping lostFocus event

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:

--
-- Grid lost-focus sample for Tony Steward
--
-- Phil Russell May 2005

without warning

include win32lib.ew
include	eugrid.ew

atom		void
integer		Grid, colEditable, colName, colDOB, colPhone
integer		grid_has_focus grid_has_focus=0

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"		}
}

--*------------------------------------------------------*
-- 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 )

-- Name column
colName	 = EGW_AddColumn( Grid, "Name", 100, EGW_LAST, EGW_EDIT, 2 )

-- 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 )

-- Phone Number column
colPhone = EGW_AddColumn( Grid, "Phone", 100, EGW_LAST, EGW_EDIT, 4 )
void 	 = EGW_SetColumnProperty( Grid, colPhone, EGW_COL_ALIGN, EGW_CENTER )

-- Load dataset into grid
void = EGW_LoadData( Grid, GridData, EGW_REPLACE )

-- ***Set initial focus to grid
setFocus(Grid)
-- ***Record the fact
grid_has_focus=1

--*------------------------------------------------------*
-- 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 params) 
	if grid_has_focus=1 then
		grid_has_focus=0
		printf(1, "the grid lost the focus\n", {})
	end if	
end procedure

-- ***Add all other windows on form to handler list
setHandler( {Edit1,Edit2}, w32HGotFocus, routine_id("OtherWin_onGotFocus"))

--*------------------------------------------------------*
-- Open main window
--*------------------------------------------------------*-----------------------------------------------------------------------------
WinMain( MainWin, Normal  )


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 problem
and I will have another look when I get back.

HTH,

Phil

new topic     » goto parent     » topic index » view message » categorize

4. Re: EUGrid and trapping lostFocus event

------=_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!

new topic     » goto parent     » topic index » view message » categorize

5. Re: EUGrid and trapping lostFocus event

Hi Tony,

Sorry for not replying sooner.  Been on holiday with no net access.

Replies below.

>Date: 2005 Jun 2 15:23
>From: Tony Steward <tony.steward at gmail.com>
>Subject: Re: EUGrid and trapping lostFocus event

>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. 

I think my suggestion should work either way.  If you have more than one grid
then you would need to test the window id rather than a global 'grid-has-focus'
flag, though.

>Traping the gotFocus of every item would be undesirable

I can understand that.  Unfortunately, as I said, this is not as easy to fix
as it might appear, and would require major surgery to the current internal
event handling.  I'll add it to my list...

Regards,

Phil

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu