Keyboard events for canvas and screen : focus
Posted: Mon Oct 14, 2019 7:27 am
Hello,
I try to give the keyboard focus to a canvas, but without success.
SetActiveGadget does nothing.
Same case for SetActiveWindow.
I must click in the canvas.
I've copied a little part of code below.
Comments are in French, but i can translate.
I also would like to sometimes open a sticky window at its front.
And open a windowed screen inside it, without loosing the focus, since i close it manually.
Any ideas ?
I try to give the keyboard focus to a canvas, but without success.
SetActiveGadget does nothing.
Same case for SetActiveWindow.
I must click in the canvas.
I've copied a little part of code below.
Comments are in French, but i can translate.
I also would like to sometimes open a sticky window at its front.
And open a windowed screen inside it, without loosing the focus, since i close it manually.
Any ideas ?
Code: Select all
If OpenWindow(#codeWindow, 0, 0, 800, 600, "Alien BASIC", #PB_Window_Background)
If CreateMenu(#menu, WindowID(#codeWindow))
MenuTitle("Files")
MenuItem(1, "New")
MenuBar()
MenuItem(2, "Load")
MenuItem(3, "Save")
MenuItem(4, "Save As...")
MenuBar()
MenuItem(5, "Close")
MenuBar()
MenuItem(9, "Quit")
MenuTitle("Run")
MenuItem(11, "Execute")
MenuTitle("?")
MenuItem(21, "Help")
MenuItem(22, "About...")
EndIf
desktop = ExamineDesktops()
CanvasGadget(#canvas, 0, 0, DesktopWidth(desktop), DesktopHeight(desktop), #PB_Canvas_Keyboard)
; gestion des événements du menu
BindMenuEvent(#menu, 9, @MenuCallBack())
BindMenuEvent(#menu, 11, @MenuCallBack())
; gestion des événements de la fenêtre d'affichage
BindEvent(#PB_Event_MoveWindow, @PositionAndSizeViewWindowCallback())
BindEvent(#PB_Event_SizeDesktop, @PositionAndSizeViewWindowCallback())
BindEvent(#PB_Event_CloseWindow, @CloseViewWindowCallback(), #viewWindow)
; gestion des événements des gadgets
BindGadgetEvent(#canvas, @CanvasKeyboardHandler())
; rendu du renderer et du curseur dans le canvas
BindEvent(#PB_Event_Timer, @ShowRendererCallback(), #codeWindow)
AddWindowTimer(#codeWindow, #rendererTimer, 50)
EndIf