WaitKey improvement and new WaitClick command
BlitzMax Forums/BlitzMax Module Tweaks/WaitKey improvement and new WaitClick command
| ||
Hi, Not really that important, but WaitKey() currently responds to mouse clicks, which is kind of illogical. So here is a quick fix, and an additional command, which waits for either a mouse click or key (well, actually that's the old WaitKey command with a new name). In: BlitzMax\mod\brl.mod\system.mod\system.bmxReplace the original WaitKey() function with this: Rem bbdoc: Wait for a key or mouse press End Rem Function WaitClick() For Local n=1 To 255 KeyHit n Next Repeat WaitSystem For Local n=1 To 255 If KeyHit(n) Return n Next Forever End function Rem bbdoc: Wait for a key press end rem Function WaitKey() For Local n=4 To 255 KeyHit n Next Repeat WaitSystem For Local n=4 To 255 If KeyHit(n) Return n Next Forever End FunctionAnd here is a small demonstration of it: Graphics 640,480,0 cls DrawText "Press a key",0,0 flip WaitKey() cls DrawText "Press a mouse button",0,0 Flip Waitmouse() cls DrawText "Press a key or mouse button",0,0 Flip WaitClick() End |