1. EUGRID problem

Hello,

I have problem with EUgrid. I have the latest version. I set property to
EGW_MULTIPLE
and do some multiple rows, everything works.  After right or left click I need
to activate popup menu. But
after any click on grid there is popup menu, but multiple selections are lost.
How to fix it ?

Vlado


Aktivujte si aj vy schranku s neobmedzenou kapacitou na ATLAS.SK.
http://mail.atlas.sk

new topic     » topic index » view message » categorize

2. Re: EUGRID problem

Hi Vlado,

Response below,

Phil (EuGrid author)

Kusnirak wrote:
> 
> Hello,
> 
> I have problem with EUgrid. I have the latest version. I set property to
> EGW_MULTIPLE
> and do some multiple rows, everything works.  After right or left click I need
> to activate popup menu. But
> after any click on grid there is popup menu, but multiple selections are lost.
> How to fix it ?
> 
> Vlado
> 
> 
> Aktivujte si aj vy schranku s neobmedzenou kapacitou na ATLAS.SK.
> <a href="http://mail.atlas.sk">http://mail.atlas.sk</a>
> 
> 

You *can* do this but you will need to do a bit of surgery to EuGrid itself by
replacing the EGW_OnRightMouseDown function as follows:
--*------------------------------------------------------*
--* EGW_OnRightMouseDown - right mouse button down
--*------------------------------------------------------*
function EGW_OnRightMouseDown( integer grid, integer id, atom hwnd, atom x, atom
y )
	sequence cell, oldcell, rect
	integer	 index, bret

	-- 130 Set last click position
	GridProperty[grid][EGW_MOUSE_CLICK_POSITION] = {x, y}
	
	-- Find the clicked cell [row, col]
	cell = EGW_GetCellFromPoint( id, x, y )

	-- 133 Notify window of right mouse click
	bret = sendMessage( id, EGW_RIGHTBUTTONDOWN, cell[ROW], cell[COL_ID] )
	if bret then
	 return false
    end if
	
	-- If cell has changed then validate change
	if not EGW_CellChange( id, grid, GridCurrentCell[grid], cell) then
 	 return false
	end if

	-- Save any changes
	void = EGW_SaveDataForCell ( grid, GridCurrentCell[grid] )

	-- Set current cell
	GridCurrentCell[grid] = cell
			
	-- Clear all selected rows
	void = EGW_SetRowSelect(grid, cell, cell, true )
			
	repaintWindow(id)
					
	-- 133 Notify window of right mouse click
	--bret = sendMessage( id, EGW_RIGHTBUTTONDOWN, cell[ROW], cell[COL_ID] )
	
	-- if user returned zero from message
	-- and sorting allowed
	-- and clicked in column header then show sorting menu
	if bret=0
	and cell[ROW]=0 and cell[COL_ID]>0 
	and GridProperty[grid][EGW_ALLOW_COL_SORT] = true then

		if cell[ROW]=0 and cell[COL_ID]>0 then
			-- Popup sort menu
	    	-- 131 Fix for menu position problem
 	    	if Win32LibVersion[2] > 59 then
 	    		popup( {GridMenu[grid][SORTMENU], id}, x, y )
 	    	else
 	    		popup( GridMenu[grid][SORTMENU], x, y )
 	    	end if
		end if
	end if

	return true
end function


Having done this, you can trap the right mouse button to pop up a menu.  Here is
a basic example which seems to work for me:

-- Example for vlado showing multiple select and menu pop-up on right mouse
button
--
-- Phil Russell March 2006
without warning

include win32lib.ew
include	eugrid.ew

atom		void
integer		grid1, colname, coldob, colphone, colemail
integer		popMenu, popItem1, popItem2

constant testdata =
{
	{"Nobby Wombat",	"23-04-66",	"01273 772244",	"nobby at aol.com"		},
	{"Benny Bear", 		"01-05-77", "0181 123456",	"benny at aol.com"		},
	{"Carl Cat", 		"22-07-92", "01273 665544",	"carlcat at aol.com"	},
	{"Winnie Wallaby",	"20-05-54", "0208 6772555",	"winnie at aol.com"	},
	{"Sid Snake", 		"17-09-01", "01273 998877",	"sid at aol.com"		},
	{"Fred Frog", 		"05-12-95", "01273 010101",	"fred at frog.com"		},
	{"Steve Sheep", 	"17-09-01", "01273 498857",	"steve at aol.com"		},
	{"Dennis Dog", 		"12-09-55", "01273 999999",	"dennis at aol.com"	},
	{"Bjorn Badger", 	"02-11-88", "09191 224455",	"bjorn at virgin.net"	},
	{"Pete Platypus",	"02-02-77", "0208 1996678",	"pete at aol.com"		},
	{"Velma Vole", 		"10-09-43", "01273 121212",	"velma at aol.com"		},
	{"Eric Bison", 		"17-12-66", "01273 202020",	"eric at bison.com"	},
	{"Percy Pig", 		"23-09-49", "01273 554433",	"hogboy at aol.com"	},
	{"Bill Beetle", 	"13-10-84", "01203 191919",	"creepy at aol.com"	}
}

--*------------------------------------------------------*
-- Top level window
--*------------------------------------------------------*
constant MainWin = create( Window, "EuGrid Demo", 0, 50, 50, 480, 400, 0 )

--*------------------------------------------------------*
-- First grid window
--*------------------------------------------------------*
-- Create grid, create parms=(parent, x, y, width, height, show_window)
grid1 = EGW_CreateGrid( MainWin, 10, 15, 450, 200, EGW_True )

-- Set row header to display row number
void	 = EGW_SetGridProperty( grid1, EGW_ROW_HEADER_DATACOL, EGW_ROWNUM )

-- Multiple row selection
void 	 = EGW_SetGridProperty( grid1, EGW_ROW_SELECT, EGW_MULTIPLE )

-- Name column - static text, left-aligned by default
colname	 = EGW_AddColumn( grid1, "Name (Static)", 100, EGW_LAST, EGW_STATIC, 1 )
void 	 = EGW_SetColumnProperty( grid1, colname, EGW_COL_WIDTH, 75 )

-- Date of Birth column, editable + right aligned
coldob = EGW_AddColumn( grid1, "DOB", 100, EGW_LAST, EGW_EDIT, 2 )
void 	 = EGW_SetColumnProperty( grid1, coldob, EGW_COL_ALIGN, EGW_RIGHT )

-- Phone Number column, non-editable but selectable, center-aligned
colphone = EGW_AddColumn( grid1, "Phone", 100, EGW_LAST, EGW_EDIT, 3 )
void 	 = EGW_SetColumnProperty( grid1, colphone, EGW_COL_ALIGN, EGW_CENTER )
-- Set to maximum of 10 characters
void 	 = EGW_SetColumnProperty( grid1, colphone, EGW_COL_MAXCHARS, 10 )

-- Email Address column, editable, left aligned by default
colemail = EGW_AddColumn( grid1, "Email", 125, EGW_LAST, EGW_EDIT, 4 )

-- Load dataset into grid1
void = EGW_LoadData( grid1, testdata, EGW_REPLACE )

--*------------------------------------------------------*
-- Popup Menu
--*------------------------------------------------------*
popMenu   = create( Popup, "", grid1, 0, 0, 0, 0, 0 )
popItem1  = create( MenuItem, "Item &1", popMenu, 0, 0, 0, 0, 0 )
popItem2  = create( MenuItem, "Item &2", popMenu, 0, 0, 0, 0, 0 )

--*------------------------------------------------------*
-- Grid message handler
--*------------------------------------------------------*
procedure grid1_onEvent (integer self, integer event, sequence params) 

	atom 	msg, wParam, lParam
	object  void
	sequence click_pos

	msg = params[1]
	wParam = params[2]
	lParam = params[3]

	-- Suppress default processing of right mouse button
	if msg = EGW_RIGHTBUTTONDOWN then
		returnValue(1)
	-- Popup menu on clicked cell
	elsif msg = EGW_RIGHTBUTTONUP then
	
		-- Get position of mouse as at last click - returns {x,y}
		click_pos = EGW_GetGridProperty( self, EGW_MOUSE_CLICK_POSITION )
		
		-- integer check to avoid blowing up ClientToScreen
		if integer(click_pos[1]) and integer(click_pos[2]) then
			-- fix needed for different win32lib versions
		  	if Win32LibVersion[2] > 59 then
 	    		popup( {popMenu, self}, click_pos[1], click_pos[2]  )
 	    	else
 	    		popup( popMenu, click_pos[1], click_pos[2] )
 	    	end if
		end if
	end if

end procedure
setHandler( grid1, w32HEvent, routine_id("grid1_onEvent"))

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


HTH.

Cheers,

Phil

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

Search



Quick Links

User menu

Not signed in.

Misc Menu