How to connect wxEVT_KEY_DOWN?

BlitzMax Modules Forums/Brucey's Modules/How to connect wxEVT_KEY_DOWN?

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.

If you want to use Max2D style keyboard capture on a GLCanvas, you can do something like this :

...
Type MyCanvas Extends wxGLCanvas


	Method OnInit()
		
		EnablePolledInput(Self)

		ConnectAny(wxEVT_KEY_DOWN, OnKeyDown)
		ConnectAny(wxEVT_KEY_UP, OnKeyUp)

	End Method

	Function OnKeyDown(event:wxEvent)
		Local evt:wxKeyEvent = wxKeyEvent(event)
		EmitEvent(CreateEvent( EVENT_KEYDOWN, event.parent, MapWxKeyCodeToBlitz(evt.GetKeyCode())))
		event.Skip()
	End Function

	Function OnKeyUp(event:wxEvent)
		Local evt:wxKeyEvent = wxKeyEvent(event)
		EmitEvent(CreateEvent( EVENT_KEYUP, event.parent, MapWxKeyCodeToBlitz(evt.GetKeyCode())))
		event.Skip()
	End Function

...

End Type


And then, in your OnPaint event, you can work much like you would with Max2D, using things like KeyDown() and KeyUp() to determine current key states.

Are you using the custom appstub for OS X? That fixes numerous problems with BRL's appstub and the fact it is designed to work with Cocoa.