Re: New to Euphoria and GUI

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Tue, 17 Jun 2003 20:30:38 +1200, Ray Tomes <rtomes at ihug.co.nz>
wrote:

>I cannot find a keystroke capture demo though, and that is the thing I=20
>need.

Hi Ray,
I wrote a program for a Finnish user having trouble with their
keyboard a few weeks ago. I've cleaned it up as a demo for you, see
below.

>    parms =3D { integer keyCode, integer shift}
>Now I find this confusing.  It says "Const" and then it says "parms".=20
w32HKeyPress and w32HKeyDown are constants that you use in setHandler
to associate routines with those events. It is describing the
parameter passed to the routines. See below, keycode=3Dparams[1] and
shift=3Dparams[2] at the start of keyboardEvent().

Pete

without warning
include win32lib.ew

constant MAIN=3Dcreate(Window,"Finnish",0,50,50,400,180,0),
		 lab1=3Dcreate(LText,"",MAIN,10,10,300,25,0),
		 lab2=3Dcreate(LText,"",MAIN,10,40,300,25,0),
		 lab3=3Dcreate(LText,"",MAIN,10,70,300,25,0),
		 lab4=3Dcreate(LText,"",MAIN,10,100,300,25,0),
		 labl=3D{lab1,lab2,lab3,lab4}
sequence keys, funcs, funcdes
keys=3D"{}\\@"
funcs=3D{VK_RETURN,VK_LEFT,VK_F1,VK_PAGEDOWN}
funcdes=3D{"Return","Left","F1","Page Down"}

integer next
		next=3D0

procedure st()
	next+=3D1
	if keys[1]=3D'{' then
		setText(labl[next],"Press "&keys[next])
	else
		setText(labl[next],"Press "&funcdes[next])
	end if
end procedure
st()

procedure keyboardEvent(integer self, integer event, sequence params)
integer keycode, shift
	keycode=3Dparams[1]
	shift=3Dparams[2]
	setText(MAIN,sprintf("%02x %02x",{keycode,shift}))

	if keycode=3Dkeys[next] then
		if next=3Dlength(keys) then
			if keys[1]=3D'{' then
				for i=3D1 to length(keys) do
					setText(labl[i],"")
				end for
				next=3D0
				keys=3Dfuncs*-1
			else
				closeWindow(MAIN)
				return
			end if
		end if
		st()
	end if
end procedure
setHandler(MAIN,w32HKeyPress,routine_id("keyboardEvent"))

procedure convertSpecialKeys(integer self, integer event, sequence
params)
	-- send special keys as negative to distinguish from 'normal' keys
	params[1]*=3D-1
	keyboardEvent(self,event,params)
end procedure
setHandler(MAIN,w32HKeyDown,routine_id("convertSpecialKeys"))

WinMain(MAIN,Normal)

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu