Page 1 of 1

Keyboard and windowdScreen

Posted: Tue Apr 23, 2013 1:17 pm
by Rings
if i used a windowd-Screen, no keyboard functions work.
can anyone confirm ?
(linux Mint in a vm-ware )

Code: Select all

;
; ------------------------------------------------------------
;
;   PureBasic - Keyboard example file
;
;    (c) 2001 - Fantaisie Software
;
; ------------------------------------------------------------
;

If InitKeyboard() = 0 Or InitSprite() = 0
  MessageRequester("Error", "Can't initialize the sprite system.", 0)
  End
EndIf

MessageRequester("Information", "This will test the fast keyboard access..."+#LF$+"Press 'ESC' to quit!", 0)

w=800
h=600
;If OpenScreen(800, 600, 32, "Keyboard")=0:MessageRequester("Info","Error OpenScreen!",0):EndIf
 If OpenWindow(0, 10, 10, w, h, "Hangman V1.0 - build 4", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)=0:MessageRequester("Info","Error OpenWindow!",0):EndIf
   If OpenWindowedScreen(WindowID(0), 0, 0, w,h)=0:MessageRequester("Info","Error OpenWindowScreen!",0):EndIf
; If w>0   
  x = 100
  y = 100
  
  LoadSprite(0, "Data/PureBasic.bmp", 0)

  Repeat
  
    FlipBuffers()
    
    ClearScreen(RGB(0,0,0))
  
    ExamineKeyboard()
    
    If KeyboardPushed(#PB_Key_Left)
      x-1
    EndIf
  
    If KeyboardPushed(#PB_Key_Right)
      x+1
    EndIf
  
    If KeyboardPushed(#PB_Key_Up)
      y-1
    EndIf
  
    If KeyboardPushed(#PB_Key_Down)
      y+1
    EndIf
    
    For OffsetY=0 To 600 Step 70
      For OffsetX=0 To 800 Step 200
        DisplaySprite(0, OffsetX+x, y+OffsetY)
      Next
      
      For OffsetX=0 To 800 Step 200
        DisplaySprite(0, OffsetX+x+90, y+OffsetY+35)
      Next
    Next
    
  Until KeyboardPushed(#PB_Key_Escape)
  
  End
  

Re: Keyboard and windowdScreen

Posted: Tue Apr 23, 2013 3:03 pm
by Shardik
Rings wrote:if i used a windowd-Screen, no keyboard functions work.
can anyone confirm ?
(linux Mint in a vm-ware )
After having changed

Code: Select all

LoadSprite(0, "Data/PureBasic.bmp", 0)
to

Code: Select all

LoadSprite(0, #PB_Compiler_Home + "examples/sources/Data/PureBasic.bmp", 0)
I can confirm that the keyboard keys do not work on these distributions running on real hardware:
- Fedora 17 x86
- Linux Mint 14 Cinnamon x86
- Kubuntu 12.10 x86
- Ubuntu 12.10 Unity x86

Re: Keyboard and windowdScreen

Posted: Thu Apr 25, 2013 4:17 pm
by Kuron
Happens here too

Re: Keyboard and windowdScreen

Posted: Sat Apr 27, 2013 8:03 am
by BasicallyPure
After I add this line inside the loop it works for me.
Ubuntu 12.10 x64

Code: Select all

     While WindowEvent() : Wend

Re: Keyboard and windowdScreen

Posted: Tue Sep 30, 2014 9:43 am
by Fred
You need an event loop.