Re: onKeyDown
- Posted by bobspringett <bobspringett at WANADOO.FR> Aug 16, 2000
- 456 views
Thanks very much Dan. I think that this willl explain a lot to me. Regards Bob ----- Original Message ----- From: Dan B Moyer <DANMOYER at PRODIGY.NET> To: <EUPHORIA at LISTSERV.MUOHIO.EDU> Sent: Wednesday, August 16, 2000 10:26 AM Subject: Re: onKeyDown > Bob, > > Although I'm anything but an expert, it looks to me that at least as far as > what you've said, what you're doing is perfectly correct. If it will help > you debug your efforts, here's some code that demonstrates what you want; I > included two ways to do it, one with nexted if's to allow for various > <ctrl>key combos, and then one for just <ctrl>right arrow using "if-and" > just > like you did (last example overwrites the first): > > <tested code follows:> > > -- demonstrates using the arrow keys in conjunction with <control> key: > > include Win32Lib.ew > without warning > > constant MainWin = create(Window,"Press Arrow Keys and <control>key > together",0,0,0,400,400,0) > > -------------------------------------------------------------------- > > procedure MainWin_onKeyDown ( int scanCode, int shift ) > > > -- first way provides for any arrow key plus <control>: > > -- IF CONTROL KEY PRESSED: > if and_bits(shift,ControlMask) then -- control key pressed > > -- if control key and AN ARROW KEY PRESSED: > > -- UP ARROW > if scanCode = VK_UP then > repaintWindow(MainWin) > wPuts(MainWin,"<control>up arrow") > > -- DOWN ARROW > elsif scanCode = VK_DOWN then > repaintWindow(MainWin) > wPuts(MainWin,"<control>down arrow") > > -- LEFT ARROW > elsif scanCode = VK_LEFT then > repaintWindow(MainWin) > wPuts(MainWin,"<control>left arrow") > > -- RIGHT ARROW > elsif scanCode = VK_RIGHT then > repaintWindow(MainWin) > wPuts(MainWin,"<control>right arrow") > > end if > end if > > -- second way uses combined if test for <control> & right arrow: > > if and_bits(shift,ControlMask) and scanCode = VK_RIGHT then > repaintWindow(MainWin) > wPuts(MainWin,"second way works too: <control>right arrow") > end if > > end procedure > ------------------------------------------------------------ > > onKeyDown[MainWin] = routine_id("MainWin_onKeyDown") > > ----------------------------------------------------------- > > WinMain( MainWin, Normal ) > > <code ends> > > HTH, > Dan Moyer > > ----- Original Message ----- > From: "bobspringett" <bobspringett at WANADOO.FR> > To: <EUPHORIA at LISTSERV.MUOHIO.EDU> > Sent: Tuesday, August 15, 2000 10:02 AM > Subject: onKeyDown > > > > I am trying to call a procedure using the onKeyDown(scanCode,shift) > function . In the proc I'm using 'if and_bits(shift,ControlMask) > > and scanCode=VK_RIGHT then' > > "do something". > > When holding down the CTRL +RIGHTARROW KEY nothing happens. > > However when I hold down SHIFT CTRL ALT + RIGHTARROW KEY it works. Seems > like I've got the ControlMask screwed up. Can someone help > > me please. > > Regards > > Bob