I try to create a CLI on Spider.
Is it possible to get the keys pushed from a "background" window (with a canvas on it), or do we need Screens/Sprite for this?
How to read keyboard keys into a window
Re: How to read keyboard keys into a window
Canvas should work, did you tried ?
Re: How to read keyboard keys into a window
I remember failing with this idea years ago, so here i try again:
I get 0 and "" only, but should not be any input when pressing a key? (I click the canvas twice so that it has focus, once is no enough)
Code: Select all
global *window
global *canvas
procedure sizing ( )
resizeGadget ( *canvas,
0,
0,
windowWidth ( *window ),
windowHeight ( *window ) )
endprocedure
procedure canvas_event ( )
debug getGadgetAttribute ( *canvas,
#pb_canvas_input )
debug chr ( getGadgetAttribute ( *canvas,
#pb_canvas_key ) )
sizing ( )
endProcedure
*window = openWindow ( #pb_any,
0,
0,
0,
0,
#pb_compiler_filename,
#pb_window_background )
bindEvent ( #pb_event_sizeDesktop,
@ sizing ( ) )
bindEvent ( #pb_event_sizeWindow,
@ sizing ( ) )
*canvas = canvasGadget ( #pb_any,
0,
0,
0,
0,
#pb_canvas_keyboard )
bindEvent ( #pb_event_gadget,
@ canvas_event ( ) )
sizing ( )
Re: How to read keyboard keys into a window
Your code is... "strange" to me 
Anyway I don't know if I understand you well.
I can get key inputs (if the canvas was focused) this way:

Anyway I don't know if I understand you well.
I can get key inputs (if the canvas was focused) this way:
Code: Select all
Debug ""
Procedure Gadget_event()
If EventType()=#PB_EventType_Input
Debug Chr(GetGadgetAttribute(0, #PB_Canvas_Input))
EndIf
EndProcedure
OpenWindow(0, 0, 0, 100, 100, #PB_Compiler_Filename, #PB_Window_Background)
BindEvent(#PB_Event_Gadget, @Gadget_event())
CanvasGadget(0, 0, 0, 100, 100, #PB_Canvas_Keyboard|#PB_Canvas_DrawFocus)
SetActiveGadget(0)
Re: How to read keyboard keys into a window
this is the special "es_91"-Style.
Personally, I refuse to read this style far from any convention.
Re: How to read keyboard keys into a window
Actually not, quite. I prefer ;{;} blocks around everything.
@Caronte3D: Thank you very much! It works with that little
Code: Select all
SetActiveGadget (#gadget)