Changed setRelative to lock attribute

This commit is contained in:
Aaron Santiago
2015-03-25 23:51:31 -04:00
parent 1228ee3fe4
commit 96e33a57fb
5 changed files with 44 additions and 20 deletions

View File

@@ -10,7 +10,8 @@ class NativeMouse {
private static var __cursor:MouseCursor;
private static var __hidden:Bool;
private static var __lock:Bool;
public static function hide ():Void {
@@ -45,16 +46,30 @@ class NativeMouse {
}
public static function setRelative (value:Bool):Int {
// Get & Set Methods
public static function get_lock ():Bool {
return lime_mouse_set_relative (value);
return __lock;
}
// Get & Set Methods
public static function set_lock (value:Bool):Bool {
if (__lock != value) {
lime_mouse_set_lock (value);
__lock = value;
}
return __lock;
}
public static function get_cursor ():MouseCursor {
@@ -109,7 +124,7 @@ class NativeMouse {
private static var lime_mouse_warp_global = System.load ("lime", "lime_mouse_warp_global", 2);
private static var lime_mouse_set_relative = System.load ("lime", "lime_mouse_set_relative", 1);
private static var lime_mouse_set_lock = System.load ("lime", "lime_mouse_set_lock", 1);
private static var lime_mouse_hide = System.load ("lime", "lime_mouse_hide", 0);
private static var lime_mouse_set_cursor = System.load ("lime", "lime_mouse_set_cursor", 1);
private static var lime_mouse_show = System.load ("lime", "lime_mouse_show", 0);

View File

@@ -4,6 +4,7 @@ package lime.ui;
class Mouse {
public static var lock (get, set):Bool;
public static var cursor (get, set):MouseCursor;
@@ -24,12 +25,6 @@ class Mouse {
MouseBackend.warpGlobal(x,y);
}
public static function setRelative(value:Bool):Int {
return MouseBackend.setRelative(value);
}
@@ -38,6 +33,19 @@ class Mouse {
private static function get_lock ():Bool {
return MouseBackend.get_lock ();
}
private static function set_lock (value:Bool):Bool {
return MouseBackend.set_lock (value);
}
private static function get_cursor ():MouseCursor {
return MouseBackend.get_cursor ();

View File

@@ -15,7 +15,7 @@ namespace lime {
static MouseCursor currentCursor;
static void WarpGlobal (int x, int y);
static int SetRelative (bool value);
static void SetLock (bool value);
static void Hide ();
static void SetCursor (MouseCursor cursor);
static void Show ();

View File

@@ -524,9 +524,9 @@ namespace lime {
}
value lime_mouse_set_relative (value input_value) {
value lime_mouse_set_lock (value input_value) {
Mouse::SetRelative (input_value);
Mouse::SetLock (input_value);
return alloc_null ();
}
@@ -811,7 +811,7 @@ namespace lime {
DEFINE_PRIM (lime_lzma_encode, 1);
DEFINE_PRIM (lime_lzma_decode, 1);
DEFINE_PRIM (lime_mouse_warp_global, 2);
DEFINE_PRIM (lime_mouse_set_relative, 1);
DEFINE_PRIM (lime_mouse_set_lock, 1);
DEFINE_PRIM (lime_mouse_hide, 0);
DEFINE_PRIM (lime_mouse_set_cursor, 1);
DEFINE_PRIM (lime_mouse_show, 0);

View File

@@ -24,14 +24,15 @@ namespace lime {
}
int Mouse::SetRelative (bool value) {
void Mouse::SetLock (bool value) {
if(value)
{
return SDL_SetRelativeMouseMode(SDL_TRUE);
SDL_SetRelativeMouseMode(SDL_TRUE);
}
else
{
return SDL_SetRelativeMouseMode(SDL_FALSE);
SDL_SetRelativeMouseMode(SDL_FALSE);
}
}