Hi,
are you using TBGL "canvas" inside UI dialog, or TBGL window alone?
GetAsyncKeyState function of UI is very handy when you need to check for specific key.
TBGL_GetAsyncKeyState is TBGL equivalent, which in addition comes in flavours like TBGL_GetWindowKeyState, TBGL_GetWindowKeyOnce...
There is no need to get crazy with IFs, you can do stunts like:
[code=thinbasic]
For k = %VK_A To %VK_Z
If TBGL_GetWindowKeyOnce(hWnd, k) Then ...
Next
For k = %VK_0 To %VK_9
If TBGL_GetWindowKeyOnce(hWnd, k) Then ...
Next
[/code]
Here little, very primitive, example:
[code=thinbasic]
Uses "TBGL"
Function TBMain()
Local hWnd As DWord
Local FrameRate As Double
' -- Create and show window
hWnd = TBGL_CreateWindowEx("Write! - press ESC to quit", 640, 480, 32, %TBGL_WS_WINDOWED Or %TBGL_WS_CLOSEBOX)
TBGL_ShowWindow
Dim hFont As DWord = TBGL_FontHandle("Courier New", 9)
TBGL_BuildFont( hFont )
Dim inputStr As String
' -- Resets status of all keys
TBGL_ResetKeyState()
' -- Main loop
While TBGL_IsWindow(hWnd)
FrameRate = TBGL_GetFrameRate
TBGL_ClearFrame
TBGL_RenderMatrix2D(0, 480, 640, 0)
TBGL_PrintFont inputStr, 10, 10, 0
HandleInput(hWnd, inputStr)
TBGL_DrawFrame
' -- ESCAPE key to exit application
If TBGL_GetWindowKeyState(hWnd, %VK_ESCAPE) Then Exit While
Wend
TBGL_DestroyWindow
End Function
Function HandleInput(hWnd As DWord, ByRef s As String)
Dim k As Long
For k = %VK_A To %VK_Z
If TBGL_GetWindowKeyOnce(hWnd, k) Then s += Chr$(k)
Next
For k = %VK_0 To %VK_9
If TBGL_GetWindowKeyOnce(hWnd, k) Then s += Chr$(k)
Next
End Function
[/code]
Petr
Bookmarks