Joakim Christiansen wrote:
It's because of the windowedscreen, it sucks...
Well, its true that windowedscreen is a big pain in the *ss, but its not too hard to sort out... just need to track the cursor and release it or grab it depending on the situation. Here is some example code that was posted on the forums... fweil I think:
Code: Select all
Quit = #False
If InitSprite()
If InitKeyboard()
If InitMouse()
WindowXSize = 800
WindowYSize = 600
If OpenWindow(0,0,0,WindowXSize,WindowYSize,#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_TitleBar|#PB_Window_ScreenCentered,"demo")
hCursor1 = LoadCursor_(0, #IDC_ARROW)
hCursor2 = LoadCursor_(0, #IDC_CROSS)
AddKeyboardShortcut(0, #PB_Shortcut_Escape, #PB_Shortcut_Escape)
WindowedScreenXSize = 640
WindowedScreenYSize = 480
If OpenWindowedScreen(WindowID(),WindowXSize - WindowedScreenXSize,WindowYSize - WindowedScreenYSize,WindowedScreenXSize,WindowedScreenYSize,0,0,0)
SetFrameRate(60)
Repeat
Select WindowEvent()
Case #PB_Event_CloseWindow
Quit = #True
Case #PB_Event_Menu
Select EventMenuID()
Case #PB_Shortcut_Escape
Quit = #True
EndSelect
Case #PB_Event_Gadget
EndSelect
GetCursorPos_(CursorPosition.POINT)
MouseX = CursorPosition\x - WindowX()
MouseY = CursorPosition\y - WindowY() - 20
If MouseX >= WindowXSize - WindowedScreenXSize And MouseX <= WindowXSize And MouseY >= WindowYSize - WindowedScreenYSize And MouseY <= WindowYSize
SetCursor_(hCursor2)
Else
SetCursor_(hCursor1)
EndIf
FlipBuffers()
ClearScreen(255,255,255)
StartDrawing(ScreenOutput())
Locate(10,200)
DrawText("Mouse X/Y=("+Str(MouseX)+","+Str(MouseY)+")")
If MouseX >= WindowXSize - WindowedScreenXSize And MouseX <= WindowXSize And MouseY >= WindowYSize - WindowedScreenYSize And MouseY <= WindowYSize
Locate(10,220)
DrawText("Cursor in")
Else
Locate(10,220)
DrawText("Cursor out")
EndIf
StopDrawing()
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Escape)
Quit = #True
EndIf
Delay(10)
Until Quit
Else
MessageRequester("Error", "Can't open the main windowedscreen", 0)
EndIf
Else
MessageRequester("Error", "Can't open the main window", 0)
EndIf
Else
MessageRequester("Error", "Can't init mouse", 0)
EndIf
Else
MessageRequester("Error", "Can't init keyboard", 0)
EndIf
Else
MessageRequester("Error", "Can't init sprites", 0)
EndIf
End
mipooh wrote:Just re-downloaded the files, the´re still wrong...
Added the # here and changed the keys, so it works now.
The mouse cannot leave. Don´t know why, I think it is because of the windowedscreen, don´t know how to get the mouse out of that jail...
Not sure what went wrong with the file, but I downloaded it and the changes were there....
Anyhow, as shown in the code above, its not too hard... another option is to never actually grab the mouse with the windowed screen and then just track it and only respond to actions within the screen itself.
Code: Select all
GetCursorPos_(CursorPosition.POINT) : x = CursorPosition\x - WindowX() : y = CursorPosition\y - WindowY() - 20
And then only respond when the x and y values are within your window dimensions (640x480 or whatever). The -20 in the y section of that code is to deal with the title bar on the window.... 20 works on my machine with XP, but it guaranteed to fail on any other machine.

There are some threads for a year and a half ago where I asked about how to overcome that...
EDIT: Forum post with fweil teaching me the ways of windows:
viewtopic.php?t=10728&highlight=