Skip to content

Commit f12e548

Browse files
YourRobotOverlordtig
authored andcommitted
Allow hotkey specifier to be at any position in label (gui-cs#4067)
Allow hotkey specifier to be at any position in label "D_irectory" doesn't work because hotPos is hardcoded 0
1 parent a08ea41 commit f12e548

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Examples/UICatalog/Scenarios/FileDialogExamples.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,15 @@ private void CreateDialog ()
168168
var fd = new FileDialog
169169
{
170170
OpenMode = Enum.Parse<OpenMode> (
171-
_rgOpenMode.RadioLabels.Select (l => TextFormatter.RemoveHotKeySpecifier(l, 0, _rgOpenMode.HotKeySpecifier)).ToArray() [_rgOpenMode.SelectedItem]
171+
_rgOpenMode.RadioLabels
172+
.Select (l => TextFormatter.FindHotKey (l, _rgOpenMode.HotKeySpecifier, out int hotPos, out Key _)
173+
174+
// Remove the hotkey specifier at the found position
175+
? TextFormatter.RemoveHotKeySpecifier (l, hotPos, _rgOpenMode.HotKeySpecifier)
176+
177+
// No hotkey found, return the label as is
178+
: l)
179+
.ToArray () [_rgOpenMode.SelectedItem]
172180
),
173181
MustExist = _cbMustExist.CheckedState == CheckState.Checked,
174182
AllowsMultipleSelection = _cbAllowMultipleSelection.CheckedState == CheckState.Checked

0 commit comments

Comments
 (0)