Keyboard and windowdScreen

Just starting out? Need help? Post your questions and find answers here.
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Keyboard and windowdScreen

Post 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
  
SPAMINATOR NR.1
User avatar
Shardik
Addict
Addict
Posts: 2067
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: Keyboard and windowdScreen

Post 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
User avatar
Kuron
Addict
Addict
Posts: 1626
Joined: Sat Oct 17, 2009 10:51 pm
Location: Pacific Northwest

Re: Keyboard and windowdScreen

Post by Kuron »

Happens here too
Best wishes to the PB community. Thank you for the memories. ♥️
User avatar
BasicallyPure
Enthusiast
Enthusiast
Posts: 539
Joined: Thu Mar 24, 2011 12:40 am
Location: Iowa, USA

Re: Keyboard and windowdScreen

Post by BasicallyPure »

After I add this line inside the loop it works for me.
Ubuntu 12.10 x64

Code: Select all

     While WindowEvent() : Wend
BasicallyPure
Until you know everything you know nothing, all you have is what you believe.
Fred
Administrator
Administrator
Posts: 18350
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Keyboard and windowdScreen

Post by Fred »

You need an event loop.
Post Reply