ExcelDnaDoc icon indicating copy to clipboard operation
ExcelDnaDoc copied to clipboard

Code to add shortcut key information to model

Open Phundamentals opened this issue 4 years ago • 2 comments

Hi,

While I do understand this is not the best or proper way to request a code change, but since I'm terrible at git and have never worked with pull requests, here it is.

Can the following code or something along its lines be added to ModelHelper.cs on line 35? It adds the neccessary information for the template to actually display key combinations.

			if (excelCommand.ShortCut != null)
			{
				System.Text.RegularExpressions.Match match = System.Text.RegularExpressions.Regex.Match(excelCommand.ShortCut, "^[\\^\\+\\%\\s]*([^\\^\\+\\%\\s]+)$");
				if (match.Success)
				{
					string shortcutKeys = string.Empty;
					if (excelCommand.ShortCut.Contains("^"))
						shortcutKeys = "Ctrl ";
					if (excelCommand.ShortCut.Contains("+"))
						shortcutKeys += "Shift ";
					if (excelCommand.ShortCut.Contains("%"))
						shortcutKeys += "Alt ";
					shortcutKeys = shortcutKeys.TrimStart().Replace(" ", " + ");
					shortcutKeys += match.Groups[1].Value;
					command.ShortCut = shortcutKeys;
				}
			}

Regards,

Sascha Sanches

Phundamentals avatar Nov 12 '20 15:11 Phundamentals

Thank you @Phundamentals - that looks like a nice improvement. I'll add it to the code.

govert avatar Nov 13 '20 21:11 govert

Thank you!

Phundamentals avatar Nov 16 '20 10:11 Phundamentals