Hitting key on canvas: sound "NotAllowed" played

BlitzMax Forums/BlitzMax Programming/Hitting key on canvas: sound "NotAllowed" played

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.

Try putting a text area off the screen and when the user clicks on the canvas, put focus on the text area. The take the data from the text area and draw it to the canvas.
'Example code: DOES NOT WORK

Local Win:TGadget = CreateWindow("Blah",0,0,640,480)
Local HiddenBox:TGadget = CreateTextArea(1000,1000,0,0,Win)
Local DrawToCanvas:TGadget = CreateCanvas(0,0,640,480,Win)

Repeat
    WaitEvent()
    Select EventId()
        Case EVENT_MOUSEHIT
            ActivateGadget(HiddenBox)
            DrawCanvasCaret(MouseX(),MouseY())
        Case EVENT_GADGETACTION
            If EventSource() = HiddenBox Then
                DrawTextOnCanvas()
            EndIf
        Case EVENT_GADGETPAINT
            DrawTextOnCanvas()
            DrawCanvasCaret()
    EndSelect
Until EventId() = EVENT_WINDOWCLOSE
End

Function DrawCanvasCaret(X:Int, Y:Int)
    'Draw the caret at the mouse position
EndFunction

Function DrawTextOnCanvas()
    Local Txt:String = TextAreaText(HiddenBox)
    'Draw the data from "Txt" to the canvas
EndFunction
This is a VERY basic example but with a few improvements, this could be what you are looking for.

EDIT: Another note: Trap keystrokes (like left and right keys) so you can move the caret inside the canvas.