# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1637010752 0 # Node ID 0d5e99279c8b3efc57eca3e5653d767715d1c509 # Parent 5c43d1ee97364dc59e6ae3b7092ee64ce9b44fe7 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. diff -r 5c43d1ee9736 -r 0d5e99279c8b ios/dw.m --- 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; } /*