File tree Expand file tree Collapse file tree 1 file changed +22
-3
lines changed
Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,6 @@ public Form1()
4444 InitMapString ( ) ;
4545 InitPresetButtons ( ) ;
4646 UpdateMapStringBox ( ) ;
47- //TODO add event handler for preset buttons, it needs a handle to the XMapLibWrapper and probably the form too.
4847 }
4948 private void InitPresetButtons ( )
5049 {
@@ -164,8 +163,28 @@ private void ButtonForPresetSection_Click(object? sender, EventArgs e)
164163 {
165164 if ( sender is Button b )
166165 {
167- bool unselect = KeymapPresetOperations . IsButtonTextSelected ( b ) ;
168- KeymapPresetOperations . ChangeButtonTextForSelected ( b , ! unselect ) ;
166+ bool isButtonTextSelected = KeymapPresetOperations . IsButtonTextSelected ( b ) ;
167+ //if is selected, do nothing, otherwise..
168+ if ( ! isButtonTextSelected )
169+ {
170+ //set each button to not selected.
171+ foreach ( var p in presets )
172+ {
173+ if ( KeymapPresetOperations . IsButtonTextSelected ( p . ButtonForPresetSection ) )
174+ KeymapPresetOperations . ChangeButtonTextForSelected ( p . ButtonForPresetSection , false ) ;
175+ }
176+ //select sending button
177+ KeymapPresetOperations . ChangeButtonTextForSelected ( b , ! isButtonTextSelected ) ;
178+ //find button in preset list, change keymaps over.
179+ mapper . ClearKeyMaps ( ) ;
180+ foreach ( var p in presets )
181+ {
182+ if ( p . ButtonForPresetSection == b )
183+ {
184+ mapper . AddKeymaps ( p . Keymaps ) ;
185+ }
186+ }
187+ }
169188 }
170189 }
171190 }
You can’t perform that action at this time.
0 commit comments