瀏覽代碼

Allow hotkey specifier to be at any position in label (#4067)

Allow hotkey specifier to be at any position in label

"D_irectory" doesn't work because hotPos is hardcoded 0
M3Logic 4 月之前
父節點
當前提交
f12e5483dc
共有 1 個文件被更改,包括 9 次插入1 次删除
  1. 9 1
      Examples/UICatalog/Scenarios/FileDialogExamples.cs

+ 9 - 1
Examples/UICatalog/Scenarios/FileDialogExamples.cs

@@ -168,7 +168,15 @@ public class FileDialogExamples : Scenario
         var fd = new FileDialog
         {
             OpenMode = Enum.Parse<OpenMode> (
-                                             _rgOpenMode.RadioLabels.Select (l => TextFormatter.RemoveHotKeySpecifier(l, 0, _rgOpenMode.HotKeySpecifier)).ToArray() [_rgOpenMode.SelectedItem]
+                                             _rgOpenMode.RadioLabels
+                                                        .Select (l => TextFormatter.FindHotKey (l, _rgOpenMode.HotKeySpecifier, out int hotPos, out Key _)
+
+                                                                          // Remove the hotkey specifier at the found position
+                                                                          ? TextFormatter.RemoveHotKeySpecifier (l, hotPos, _rgOpenMode.HotKeySpecifier)
+
+                                                                          // No hotkey found, return the label as is
+                                                                          : l)
+                                                        .ToArray () [_rgOpenMode.SelectedItem]
                                             ),
             MustExist = _cbMustExist.CheckedState == CheckState.Checked,
             AllowsMultipleSelection = _cbAllowMultipleSelection.CheckedState == CheckState.Checked