2 Subject: Patch 7.1.285 (extra)
4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
11 Problem: Mac: dialog hotkeys don't work.
12 Solution: Add hotkey support. (Dan Sandler)
16 *** ../vim-7.1.284/src/gui_mac.c Wed Mar 12 21:47:31 2008
17 --- src/gui_mac.c Sun Mar 16 15:25:13 2008
21 /* Keeping track of which scrollbar is being dragged */
22 static ControlHandle dragged_sb = NULL;
24 + /* Vector of char_u --> control index for hotkeys in dialogs */
25 + static short *gDialogHotKeys;
33 SetDialogItemText(itemHandle, itemName);
37 + /* ModalDialog() handler for message dialogs that have hotkey accelerators.
38 + * Expects a mapping of hotkey char to control index in gDialogHotKeys;
39 + * setting gDialogHotKeys to NULL disables any hotkey handling.
41 + static pascal Boolean
42 + DialogHotkeyFilterProc (
43 + DialogRef theDialog,
45 + DialogItemIndex *itemHit)
49 + if (event->what == keyDown || event->what == autoKey)
51 + keyHit = (event->message & charCodeMask);
53 + if (gDialogHotKeys && gDialogHotKeys[keyHit])
55 + #ifdef DEBUG_MAC_DIALOG_HOTKEYS
56 + printf("user pressed hotkey '%c' --> item %d\n", keyHit, gDialogHotKeys[keyHit]);
58 + *itemHit = gDialogHotKeys[keyHit];
60 + /* When handing off to StdFilterProc, pretend that the user
61 + * clicked the control manually. Note that this is also supposed
62 + * to cause the button to hilite briefly (to give some user
63 + * feedback), but this seems not to actually work (or it's too
66 + event->what = kEventControlSimulateHit;
68 + return true; /* we took care of it */
71 + /* Defer to the OS's standard behavior for this event.
72 + * This ensures that Enter will still activate the default button. */
73 + return StdFilterProc(theDialog, event, itemHit);
75 + return false; /* Let ModalDialog deal with it */
79 /* TODO: There have been some crashes with dialogs, check your inbox
88 + short hotKeys[256]; /* map of hotkey -> control ID */
99 + ModalFilterUPP dialogUPP;
101 /* Check 'v' flag in 'guioptions': vertical button placement. */
102 vertical = (vim_strchr(p_go, GO_VERTICAL) != NULL);
107 buttonChar = buttons;
110 + /* initialize the hotkey mapping */
111 + memset(hotKeys, 0, sizeof(hotKeys));
113 for (;*buttonChar != 0;)
115 /* Get the name of the button */
120 if (*buttonChar != DLG_HOTKEY_CHAR)
121 name[++len] = *buttonChar;
124 + aHotKey = (char_u)*(buttonChar+1);
125 + if (aHotKey >= 'A' && aHotKey <= 'Z')
126 + aHotKey = (char_u)((int)aHotKey + (int)'a' - (int)'A');
127 + hotKeys[aHotKey] = button;
128 + #ifdef DEBUG_MAC_DIALOG_HOTKEYS
129 + printf("### hotKey for button %d is '%c'\n", button, aHotKey);
134 if (*buttonChar != 0)
140 (void) C2PascalString(textfield, &name);
141 SetDialogItemText(itemHandle, name);
142 inputItm.width = StringWidth(name);
144 + /* Hotkeys don't make sense if there's a text field */
145 + gDialogHotKeys = NULL;
148 + /* Install hotkey table */
149 + gDialogHotKeys = (short *)&hotKeys;
151 /* Set the <ENTER> and <ESC> button. */
152 SetDialogDefaultItem(theDialog, dfltbutton);
158 /* Hang until one of the button is hit */
161 ! ModalDialog(nil, &itemHit);
162 } while ((itemHit < 1) || (itemHit > lastButton));
164 #ifdef USE_CARBONKEYHANDLER
169 + /* Prepare the shortcut-handling filterProc for handing to the dialog */
170 + dialogUPP = NewModalFilterUPP(DialogHotkeyFilterProc);
172 /* Hang until one of the button is hit */
175 ! ModalDialog(dialogUPP, &itemHit);
176 } while ((itemHit < 1) || (itemHit > lastButton));
178 #ifdef USE_CARBONKEYHANDLER
182 /* Restore the original graphical port */
185 + /* Free the modal filterProc */
186 + DisposeRoutineDescriptor(dialogUPP);
188 /* Get ride of th edialog (free memory) */
189 DisposeDialog(theDialog);
191 *** ../vim-7.1.284/src/version.c Thu Mar 20 13:22:47 2008
192 --- src/version.c Thu Mar 20 14:38:06 2008
196 { /* Add new patch number below this line */
202 hundred-and-one symptoms of being an internet addict:
203 163. You go outside for the fresh air (at -30 degrees) but open the
204 window first to hear new mail arrive.
206 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
207 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
208 \\\ download, build and distribute -- http://www.A-A-P.org ///
209 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///