KeyDown(KEY_ESCAPE) Fails

BlitzMax Forums/BlitzMax Programming/KeyDown(KEY_ESCAPE) Fails

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

James, thanks for the reply. Not what I wanted to hear! Windows and Mac versions of the code work perfectly but Linux is again different?

Here is the modified code that gives suprise results. Hold a key down and watch the debug output. Where are the EVENT_KEYUP's coming from?

Const WINDOW_WIDTH=640
Const WINDOW_HEIGHT=384

Global hit[1024]

Function MyKeyDown( key:Int )
	Return HIT[Key]
End Function

Local wx=(GadgetWidth(Desktop())-WINDOW_WIDTH)/2
Local wy=(GadgetHeight(Desktop())-WINDOW_HEIGHT)/2
Global main_window:TGadget = CreateWindow( Title$,wx,wy,WINDOW_WIDTH,WINDOW_HEIGHT,Null,WINDOW_TITLEBAR | WINDOW_CLIENTCOORDS)
Global canvas:TGadget=CreateCanvas(0,0,WINDOW_WIDTH,WINDOW_HEIGHT,main_window)
SetGraphics CanvasGraphics(canvas)

ActivateGadget canvas

CreateTimer(10)

'enablepolledinput()

While WaitEvent()

	Select	EventID()

		Case EVENT_WINDOWCLOSE
			End

		Case EVENT_KEYUP
			DebugLog "KEY UP"
			Select EventData()
				Case KEY_LEFT
					HIT[KEY_LEFT]=0
			End Select
			
		Case EVENT_KEYDOWN
			DebugLog "KEY DOWN"
			Select EventData()
				Case KEY_LEFT
					HIT[KEY_LEFT]=1
			End Select

		Case EVENT_TIMERTICK

			If MyKeyDown(KEY_LEFT)
				SetClsColor Rnd(255),Rnd(255),Rnd(255)
				Cls
				Flip
			EndIf

	EndSelect

End While