Window: add new setTextInputRect() method to optionally specify the location of the input when textInputEnabled is set to true
On native, this uses SDL_SetTextInputRect
This commit is contained in:
@@ -57,6 +57,7 @@ namespace lime {
|
||||
virtual void SetMouseLock (bool mouseLock) = 0;
|
||||
virtual bool SetResizable (bool resizable) = 0;
|
||||
virtual void SetTextInputEnabled (bool enable) = 0;
|
||||
virtual void SetTextInputRect (Rectangle *rect) = 0;
|
||||
virtual const char* SetTitle (const char* title) = 0;
|
||||
virtual void WarpMouse (int x, int y) = 0;
|
||||
|
||||
|
||||
@@ -3668,6 +3668,23 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
void lime_window_set_text_input_rect (value window, value rect) {
|
||||
|
||||
Window* targetWindow = (Window*)val_data (window);
|
||||
Rectangle _rect = Rectangle (rect);
|
||||
targetWindow->SetTextInputRect (&_rect);
|
||||
|
||||
}
|
||||
|
||||
|
||||
HL_PRIM void HL_NAME(hl_window_set_text_input_rect) (HL_CFFIPointer* window, Rectangle* rect) {
|
||||
|
||||
Window* targetWindow = (Window*)window->ptr;
|
||||
targetWindow->SetTextInputRect (rect);
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_window_set_title (value window, HxString title) {
|
||||
|
||||
Window* targetWindow = (Window*)val_data (window);
|
||||
@@ -3931,6 +3948,7 @@ namespace lime {
|
||||
DEFINE_PRIME2v (lime_window_set_mouse_lock);
|
||||
DEFINE_PRIME2 (lime_window_set_resizable);
|
||||
DEFINE_PRIME2v (lime_window_set_text_input_enabled);
|
||||
DEFINE_PRIME2v (lime_window_set_text_input_rect);
|
||||
DEFINE_PRIME2 (lime_window_set_title);
|
||||
DEFINE_PRIME3v (lime_window_warp_mouse);
|
||||
DEFINE_PRIME2 (lime_zlib_compress);
|
||||
@@ -4114,6 +4132,7 @@ namespace lime {
|
||||
DEFINE_HL_PRIM (_VOID, hl_window_set_mouse_lock, _TCFFIPOINTER _BOOL);
|
||||
DEFINE_HL_PRIM (_BOOL, hl_window_set_resizable, _TCFFIPOINTER _BOOL);
|
||||
DEFINE_HL_PRIM (_VOID, hl_window_set_text_input_enabled, _TCFFIPOINTER _BOOL);
|
||||
DEFINE_HL_PRIM (_VOID, hl_window_set_text_input_rect, _TCFFIPOINTER _TRECTANGLE);
|
||||
DEFINE_HL_PRIM (_STRING, hl_window_set_title, _TCFFIPOINTER _STRING);
|
||||
DEFINE_HL_PRIM (_VOID, hl_window_warp_mouse, _TCFFIPOINTER _I32 _I32);
|
||||
DEFINE_HL_PRIM (_TBYTES, hl_zlib_compress, _TBYTES _TBYTES);
|
||||
|
||||
@@ -1050,6 +1050,23 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
void SDLWindow::SetTextInputRect (Rectangle * rect) {
|
||||
|
||||
SDL_Rect bounds = { 0, 0, 0, 0 };
|
||||
|
||||
if (rect) {
|
||||
|
||||
bounds.x = rect->x;
|
||||
bounds.y = rect->y;
|
||||
bounds.w = rect->width;
|
||||
bounds.h = rect->height;
|
||||
|
||||
}
|
||||
|
||||
SDL_SetTextInputRect(&bounds);
|
||||
}
|
||||
|
||||
|
||||
const char* SDLWindow::SetTitle (const char* title) {
|
||||
|
||||
SDL_SetWindowTitle (sdlWindow, title);
|
||||
|
||||
@@ -51,6 +51,7 @@ namespace lime {
|
||||
virtual void SetMouseLock (bool mouseLock);
|
||||
virtual bool SetResizable (bool resizable);
|
||||
virtual void SetTextInputEnabled (bool enabled);
|
||||
virtual void SetTextInputRect (Rectangle *rect);
|
||||
virtual const char* SetTitle (const char* title);
|
||||
virtual void WarpMouse (int x, int y);
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ class FlashWindow
|
||||
private var mouseLeft:Bool;
|
||||
private var parent:Window;
|
||||
private var textInputEnabled:Bool;
|
||||
private var textInputRect:Rectangle;
|
||||
private var unusedTouchesPool = new List<Touch>();
|
||||
|
||||
public function new(parent:Window)
|
||||
@@ -622,6 +623,11 @@ class FlashWindow
|
||||
return textInputEnabled = value;
|
||||
}
|
||||
|
||||
public function setTextInputRect(value:Rectangle):Rectangle
|
||||
{
|
||||
return textInputRect = value;
|
||||
}
|
||||
|
||||
public function setTitle(value:String):String
|
||||
{
|
||||
return value;
|
||||
|
||||
@@ -73,6 +73,7 @@ class HTML5Window
|
||||
private var setHeight:Int;
|
||||
private var setWidth:Int;
|
||||
private var textInputEnabled:Bool;
|
||||
private var textInputRect:Rectangle;
|
||||
private var unusedTouchesPool = new List<Touch>();
|
||||
|
||||
public function new(parent:Window)
|
||||
@@ -1165,6 +1166,11 @@ class HTML5Window
|
||||
return textInputEnabled = value;
|
||||
}
|
||||
|
||||
public function setTextInputRect(value:Rectangle):Rectangle
|
||||
{
|
||||
return textInputRect = value;
|
||||
}
|
||||
|
||||
private var inputing = false;
|
||||
|
||||
public function handleCompositionstartEvent(e):Void
|
||||
|
||||
@@ -341,6 +341,8 @@ class NativeCFFI
|
||||
|
||||
@:cffi private static function lime_window_set_text_input_enabled(handle:Dynamic, enabled:Bool):Void;
|
||||
|
||||
@:cffi private static function lime_window_set_text_input_rect(handle:Dynamic, rect:Dynamic):Void;
|
||||
|
||||
@:cffi private static function lime_window_set_title(handle:Dynamic, title:String):Dynamic;
|
||||
|
||||
@:cffi private static function lime_window_warp_mouse(handle:Dynamic, x:Int, y:Int):Void;
|
||||
@@ -593,6 +595,8 @@ class NativeCFFI
|
||||
false));
|
||||
private static var lime_window_set_text_input_enabled = new cpp.Callable<cpp.Object->Bool->cpp.Void>(cpp.Prime._loadPrime("lime",
|
||||
"lime_window_set_text_input_enabled", "obv", false));
|
||||
private static var lime_window_set_text_input_rect = new cpp.Callable<cpp.Object->cpp.Object->cpp.Void>(cpp.Prime._loadPrime("lime",
|
||||
"lime_window_set_text_input_rect", "oov", false));
|
||||
private static var lime_window_set_title = new cpp.Callable<cpp.Object->String->cpp.Object>(cpp.Prime._loadPrime("lime", "lime_window_set_title", "oso",
|
||||
false));
|
||||
private static var lime_window_warp_mouse = new cpp.Callable<cpp.Object->Int->Int->cpp.Object>(cpp.Prime._loadPrime("lime", "lime_window_warp_mouse",
|
||||
@@ -747,6 +751,7 @@ class NativeCFFI
|
||||
private static var lime_window_set_mouse_lock = CFFI.load("lime", "lime_window_set_mouse_lock", 2);
|
||||
private static var lime_window_set_resizable = CFFI.load("lime", "lime_window_set_resizable", 2);
|
||||
private static var lime_window_set_text_input_enabled = CFFI.load("lime", "lime_window_set_text_input_enabled", 2);
|
||||
private static var lime_window_set_text_input_rect = CFFI.load("lime", "lime_window_set_text_input_rect", 2);
|
||||
private static var lime_window_set_title = CFFI.load("lime", "lime_window_set_title", 2);
|
||||
private static var lime_window_warp_mouse = CFFI.load("lime", "lime_window_warp_mouse", 3);
|
||||
private static var lime_window_event_manager_register = CFFI.load("lime", "lime_window_event_manager_register", 2);
|
||||
@@ -1342,6 +1347,9 @@ class NativeCFFI
|
||||
@:hlNative("lime", "hl_window_set_text_input_enabled") private static function lime_window_set_text_input_enabled(handle:CFFIPointer,
|
||||
enabled:Bool):Void {}
|
||||
|
||||
@:hlNative("lime", "hl_window_set_text_input_rect") private static function lime_window_set_text_input_rect(handle:CFFIPointer,
|
||||
rect:Rectangle):Void {}
|
||||
|
||||
@:hlNative("lime", "hl_window_set_title") private static function lime_window_set_title(handle:CFFIPointer, title:String):String
|
||||
{
|
||||
return null;
|
||||
|
||||
@@ -546,6 +546,18 @@ class NativeWindow
|
||||
return value;
|
||||
}
|
||||
|
||||
public function setTextInputRect(value:Rectangle):Rectangle
|
||||
{
|
||||
if (handle != null)
|
||||
{
|
||||
#if (!macro && lime_cffi)
|
||||
NativeCFFI.lime_window_set_text_input_rect(handle, value);
|
||||
#end
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public function setFrameRate(value:Float):Float
|
||||
{
|
||||
// TODO: Support multiple independent frame rates per window
|
||||
|
||||
@@ -544,6 +544,11 @@ class Window
|
||||
return __backend.setTextInputEnabled(value);
|
||||
}
|
||||
|
||||
public function setTextInputRect(value:Rectangle):Rectangle
|
||||
{
|
||||
return __backend.setTextInputRect(value);
|
||||
}
|
||||
|
||||
@:noCompletion private inline function get_title():String
|
||||
{
|
||||
return __title;
|
||||
|
||||
Reference in New Issue
Block a user