[GB.SDL]
* NEW: Window.Grabbed is a new property that allows to grab the input and confine the mouse to the window. git-svn-id: svn://localhost/gambas/trunk@6359 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
c2e7d79812
commit
5318daf25a
3 changed files with 23 additions and 0 deletions
|
@ -215,6 +215,15 @@ BEGIN_PROPERTY(CWINDOW_id)
|
|||
|
||||
END_PROPERTY
|
||||
|
||||
BEGIN_PROPERTY(Window_Grabbed)
|
||||
|
||||
if (READ_PROPERTY)
|
||||
GB.ReturnBoolean(WINDOWID->IsInputGrabbed());
|
||||
else
|
||||
WINDOWID->GrabInput(VPROP(GB_BOOLEAN));
|
||||
|
||||
END_PROPERTY
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
GB_DESC CWindow[] =
|
||||
|
@ -246,6 +255,7 @@ GB_DESC CWindow[] =
|
|||
GB_PROPERTY_READ("Handle", "i", CWINDOW_id),
|
||||
GB_PROPERTY_READ("Id", "i", CWINDOW_id),
|
||||
GB_PROPERTY_READ("Shown", "b", CWINDOW_shown),
|
||||
GB_PROPERTY("Grabbed", "b", Window_Grabbed),
|
||||
|
||||
GB_EVENT("Close", "b", NULL, &EVENT_Close),
|
||||
GB_EVENT("Resize", NULL, NULL, &EVENT_Resize),
|
||||
|
|
|
@ -98,6 +98,7 @@ void SDLwindow::Close()
|
|||
if (!hSurface)
|
||||
return;
|
||||
|
||||
GrabInput(false);
|
||||
SDLcore::RegisterWindow(NULL);
|
||||
hSurface = NULL;
|
||||
}
|
||||
|
@ -256,3 +257,12 @@ bool SDLwindow::IsShown()
|
|||
return (false);
|
||||
}
|
||||
|
||||
void SDLwindow::GrabInput(bool grab)
|
||||
{
|
||||
SDL_WM_GrabInput(grab ? SDL_GRAB_ON : SDL_GRAB_OFF);
|
||||
}
|
||||
|
||||
bool SDLwindow::IsInputGrabbed(void) const
|
||||
{
|
||||
return SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_ON;
|
||||
}
|
||||
|
|
|
@ -66,6 +66,9 @@ public:
|
|||
bool IsResizable(void ) { return (hResizable); };
|
||||
bool IsShown(void );
|
||||
|
||||
void GrabInput(bool grab);
|
||||
bool IsInputGrabbed(void) const;
|
||||
|
||||
// events :)
|
||||
virtual void Quit(void ) = 0;
|
||||
virtual void Resize(void ) = 0;
|
||||
|
|
Loading…
Reference in a new issue