mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-08-26 00:33:45 +02:00
Allow empty keybinds in Cocoa menu
This commit is contained in:
parent
40ed422c3d
commit
89ebbd515a
1 changed files with 6 additions and 4 deletions
|
@ -302,6 +302,9 @@ if (!data.config.kbActionNames.value.empty()) bindingNames[@(Input::code)] = \
|
|||
- (void) loadBinds {
|
||||
[nsbinds removeAllObjects];
|
||||
|
||||
for (int i = 0; i < sizeof(inputMapRowToCode) / sizeof(Input::ButtonCode); i++)
|
||||
nsbinds[@(inputMapRowToCode[i])] = [NSMutableArray new];
|
||||
|
||||
for (int i = 0; i < binds->size(); i++) {
|
||||
NSNumber *key = @(binds->at(i).target);
|
||||
if (nsbinds[key] == nil) {
|
||||
|
@ -395,7 +398,7 @@ if (!data.config.kbActionNames.value.empty()) bindingNames[@(Input::code)] = \
|
|||
BindingIndexArray *nsbind = nsbinds[@(input)];
|
||||
NSMutableArray<NSString*> *pnames = [NSMutableArray new];
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (i > nsbind.count - 1) {
|
||||
if (!nsbind.count || i > nsbind.count - 1) {
|
||||
[pnames addObject:@"(Empty)"];
|
||||
}
|
||||
else {
|
||||
|
@ -417,15 +420,14 @@ if (!data.config.kbActionNames.value.empty()) bindingNames[@(Input::code)] = \
|
|||
- (void)enableButtons:(bool)defaultSetting {
|
||||
BindingIndexArray *currentBind = nsbinds[@(currentButtonCode)];
|
||||
bindingButton1.enabled = defaultSetting;
|
||||
bindingButton2.enabled = defaultSetting;
|
||||
bindingButton2.enabled = defaultSetting && currentBind.count > 0;
|
||||
|
||||
bindingButton3.enabled = defaultSetting && currentBind.count > 1;
|
||||
bindingButton4.enabled = defaultSetting && currentBind.count > 2;
|
||||
}
|
||||
|
||||
- (IBAction)binding1Clicked:(NSButton *)sender {
|
||||
// Need at least one binding, for now
|
||||
if (nsbinds[@(currentButtonCode)].count > 1) {
|
||||
if (nsbinds[@(currentButtonCode)].count > 0) {
|
||||
[self removeBinding:0 forInput:currentButtonCode];
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue