Skip to content

Menu-item Alt accelerators double-apply styles #151

Description

@mrhunsaker

Problem

File StyleMenuBuilder.ktgetStyleCategories (lines 90, 130–155) and currentLoadedStyle (lines 331–337)

double-fire bug. getStyleCategories attaches Alt+1–9 accelerators to the first nine menu items whose parent category/subcategory matches the current loadout. When a nested loadout is active, those per-item menu accelerators and the Alt+1–8 Display filter in addLoadoutListener both fire on the same keystroke, applying the style twice.

Fix remove the per-item accelerator logic entirely; every menu item uses accelerator 0. The Alt+1–8 Display filter becomes the single apply mechanism.

// before (relevant excerpt)
var cont = 1
...
id = id.substring(id.lastIndexOf('/') + 1)
val myCurrentLoadout = BBIni.propertyFileManager.getProperty(CURRENT_STYLE_LOADOUT_CATEGORY, "")

//TODO: Re-add shortcut functionality
//puttting shortcut in menu
val tempComp: String = if (myCurrentLoadout.contains("/")) "$cat/$afterCat" else if (afterCat == id) cat else "$cat/$afterCat"
if (myCurrentLoadout == tempComp && cont <= 9) {
    subMenu!!.addItem(
        lhb[style.name], SWT.ALT + '0'.code + cont
    ) { e: BBSelectionData -> onStyleSelect.accept(BBStyleSelection(style, e.widget)) }
    cont++
} else {
    subMenu!!.addItem(
        lhb[style.name], 0
    ) { e: BBSelectionData -> onStyleSelect.accept(BBStyleSelection(style, e.widget)) }
}
// after (relevant excerpt)
val styles = styleDefs.styles
...
// Styles are applied with Alt+1-8 from the addLoadoutListener filter keyed to the
// current style loadout, so menu items carry no per-item Alt accelerators
subMenu!!.addItem(
    lhb[style.name], 0
) { e: BBSelectionData -> onStyleSelect.accept(BBStyleSelection(style, e.widget)) }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions