changeset 2699:0d5e99279c8b

iOS: MLE work: Implement dw_mle_set_auto_complete() DW_MLE_COMPLETE_TEXT now enables and disabled iOS Auto Correct on the MLE. Attempt to get dw_mle_set_word_wrap() working, but it still doesn't seem to be working. Also added thread protection to another MLE function.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 15 Nov 2021 21:12:32 +0000
parents 5c43d1ee9736
children 246f23670e3b
files ios/dw.m
diffstat 1 files changed, 27 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/ios/dw.m	Wed Nov 03 00:51:38 2021 +0000
+++ b/ios/dw.m	Mon Nov 15 21:12:32 2021 +0000
@@ -5149,6 +5149,7 @@
 
     size.width = size.height;
     [mle setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth];
+    [mle setScrollEnabled:YES];
     [mle setTag:cid];
     [mle autorelease];
     DW_FUNCTION_RETURN_THIS(mle);
@@ -5320,17 +5321,14 @@
  *          handle: Handle to the MLE.
  *          state: TRUE if it can be edited, FALSE for readonly.
  */
-void API dw_mle_set_editable(HWND handle, int state)
+DW_FUNCTION_DEFINITION(dw_mle_set_editable, void, HWND handle, int state)
+DW_FUNCTION_ADD_PARAM2(handle, state)
+DW_FUNCTION_NO_RETURN(dw_mle_set_editable)
+DW_FUNCTION_RESTORE_PARAM2(handle, HWND, state, int)
 {
     DWMLE *mle = handle;
-    if(state)
-    {
-        [mle setEditable:YES];
-    }
-    else
-    {
-        [mle setEditable:NO];
-    }
+    [mle setEditable:(state ? YES : NO)];
+    DW_FUNCTION_RETURN_NOTHING;
 }
 
 /*
@@ -5339,9 +5337,17 @@
  *          handle: Handle to the MLE.
  *          state: TRUE if it wraps, FALSE if it doesn't.
  */
-void API dw_mle_set_word_wrap(HWND handle, int state)
-{
-    /* TODO: Figure out how to do this in iOS */
+DW_FUNCTION_DEFINITION(dw_mle_set_word_wrap, void, HWND handle, int state)
+DW_FUNCTION_ADD_PARAM2(handle, state)
+DW_FUNCTION_NO_RETURN(dw_mle_set_word_wrap)
+DW_FUNCTION_RESTORE_PARAM2(handle, HWND, state, int)
+{
+    DWMLE *mle = handle;
+    NSUInteger mask = state ? 0 :UIViewAutoresizingFlexibleWidth;
+    
+    [mle setAutoresizingMask:UIViewAutoresizingFlexibleHeight|mask];
+    [[mle textContainer] setLineBreakMode:(state ? NSLineBreakByWordWrapping : NSLineBreakByClipping)];
+    DW_FUNCTION_RETURN_NOTHING;
 }
 
 /*
@@ -5350,9 +5356,15 @@
  *          handle: Handle to the MLE.
  *          state: Bitwise combination of DW_MLE_COMPLETE_TEXT/DASH/QUOTE
  */
-void API dw_mle_set_auto_complete(HWND handle, int state)
-{
-    /* TODO: Figure out how to do this in iOS */
+DW_FUNCTION_DEFINITION(dw_mle_set_auto_complete, void, HWND handle, int state)
+DW_FUNCTION_ADD_PARAM2(handle, state)
+DW_FUNCTION_NO_RETURN(dw_mle_set_auto_complete)
+DW_FUNCTION_RESTORE_PARAM2(handle, HWND, state, int)
+{
+    DWMLE *mle = handle;
+    NSInteger autocorrect = (state & DW_MLE_COMPLETE_TEXT) ? UITextAutocorrectionTypeYes : UITextAutocorrectionTypeNo;
+    [mle setAutocorrectionType:autocorrect];
+    DW_FUNCTION_RETURN_NOTHING;
 }
 
 /*