Distinguish between normal and dialog mode for multi-line edit (MLE) controls

Mike Parker mhparker at t-online.de
Mon Apr 3 16:12:35 CDT 2006


Hi,

This patch concerns the fact that MLE controls have two modes of operation, which can be referred to as "normal mode" (as in
Notepad) and "dialog mode" (as in dialog boxes), and the discovery as to what implicitly triggers the mode switch under Windows.
In particular, the MLE's handling of both the Tab and Enter key is heavily dependent on the current operating mode.

This patch fixes bug 4381. A second example has been attached to the bug report to demonstrate some behavioral aspects not
covered by the original example.

Regards,
Mike Parker


Changelog:

Distinguish between normal and dialog mode for MLE controls
  - handle mode switch via WM_GETDLGCODE message
  - emit WM_NEXTDLGCTL in response to <Tab> key if in dialog mode
  - restrict existing ES_WANTRETURN/DM_GETDEFID handling to dialog mode  
  - allow <ctrl> key to force tab/new line insertion in dialog mode


Index: dlls/user/edit.c
===================================================================
RCS file: /home/wine/wine/dlls/user/edit.c,v
retrieving revision 1.46
diff -u -p -r1.46 edit.c
--- dlls/user/edit.c	3 Jan 2006 12:41:26 -0000	1.46
+++ dlls/user/edit.c	3 Apr 2006 08:32:32 -0000
@@ -83,6 +83,7 @@ WINE_DECLARE_DEBUG_CHANNEL(relay);
 #define EF_AFTER_WRAP		0x0080	/* the caret is displayed after the last character of a
 					   wrapped line, instead of in front of the next character */
 #define EF_USE_SOFTBRK		0x0100	/* Enable soft breaks in text. */
+#define EF_DIALOG_MODE		0x0200	/* Enable dialog (navigation) mode. */
 
 typedef enum
 {
@@ -786,6 +787,9 @@ static LRESULT WINAPI EditWndProc_common
 		
 		if (es->style & ES_MULTILINE)
 		{
+		   /* Switch over to dialog mode unless simple query request */
+		   if (lParam)
+		      es->flags |= EF_DIALOG_MODE;
 		   result |= DLGC_WANTALLKEYS;
 		   break;
 		}
@@ -3943,9 +3947,9 @@ static void EDIT_WM_Char(EDITSTATE *es, 
 
 	switch (c) {
 	case '\r':
-	    /* If the edit doesn't want the return and it's not a multiline edit, do nothing */
-	    if(!(es->style & ES_MULTILINE) && !(es->style & ES_WANTRETURN))
-		break;
+		/* In dialog mode, if the edit doesn't want the return, do nothing */
+		if((es->flags & EF_DIALOG_MODE) && !(es->style & ES_WANTRETURN) && !control)
+			break;
 	case '\n':
 		if (es->style & ES_MULTILINE) {
 			if (es->style & ES_READONLY) {
@@ -3958,7 +3962,9 @@ static void EDIT_WM_Char(EDITSTATE *es, 
 		}
 		break;
 	case '\t':
-		if ((es->style & ES_MULTILINE) && !(es->style & ES_READONLY))
+		/* In dialog mode, use <Tab> for input only if forced via <Ctrl> */
+		if ((es->style & ES_MULTILINE) && !(es->style & ES_READONLY) &&
+			(!(es->flags & EF_DIALOG_MODE) || control))
 		{
 			static const WCHAR tabW[] = {'\t',0};
 			EDIT_EM_ReplaceSel(es, TRUE, tabW, TRUE, TRUE);
@@ -4497,6 +4503,11 @@ static LRESULT EDIT_WM_KeyDown(EDITSTATE
 		else
 			EDIT_CheckCombo(es, WM_KEYDOWN, key);
 		break;
+	case VK_TAB:
+		/* <Ctrl> forces use of <Tab> for input if in dialog mode */
+		if ((es->flags & EF_DIALOG_MODE) && !control)
+			SendMessageW(es->hwndParent, WM_NEXTDLGCTL, shift, 0);
+		break;
 	case VK_DELETE:
 		if (!(es->style & ES_READONLY) && !(shift && control)) {
 			if (es->selection_start != es->selection_end) {
@@ -4533,7 +4544,7 @@ static LRESULT EDIT_WM_KeyDown(EDITSTATE
 		break;
 	case VK_RETURN:
 	    /* If the edit doesn't want the return send a message to the default object */
-	    if(!(es->style & ES_WANTRETURN))
+	    if((es->flags & EF_DIALOG_MODE) && !(es->style & ES_WANTRETURN) && !control)
 	    {
 		HWND hwndParent = GetParent(es->hwndSelf);
 		DWORD dw = SendMessageW( hwndParent, DM_GETDEFID, 0, 0 );
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bug4381_patch.diff
Type: application/octet-stream
Size: 2743 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-patches/attachments/20060403/91153c47/bug4381_patch.obj


More information about the wine-patches mailing list