separate(asud)


procedure getmouseclick( 
	mainWin : access GLFWwindow;
	wid, hit: interfaces.c.int
	) is

	msr,msl: glint;
	nowTime: float := float(glfwGetTime);
	dt : float := nowTime - mptime;
	xpos, ypos : aliased gldouble;

	function ceil( x: gldouble ) return integer is
	begin
		return integer( x+0.5 );
	end ceil;

	npr,npc: integer;

begin

	if dt>pickdwell then

		msr := glfwGetMouseButton(mainWin, glfw_mouse_button_2);
		msl := glfwGetMouseButton(mainWin, glfw_mouse_button_1);
		-- msl,msr: glint;


		if msr=glfw_press or
			msl=glfw_press	then

			mptime:=nowtime;

			glfwgetcursorpos(mainWin,xpos'access,ypos'access);

			--pick which box
			npr:=ceil(ypos/gldouble(hit)*gldouble(nrows));
			npc:=ceil(xpos/gldouble(wid)*gldouble(ncols));
			if pr=npr and pc=npc then
				pr:=0; pc:=0; --DEselect
			else
				pr:=npr; pc:=npc;
			end if;

--			digSelect := m9(pr,pc); -- NONzero=>singleton

--put("cell=("&integer'image(pr)&","&integer'image(pc)&")");
--put("  digit="&integer'image(digSelect));
--new_line;

		end if;

	end if;

end getmouseclick;


