瀏覽代碼

Raise event in SelectionGrid when appropriate

SelectionGrid would raise events even when the selection hasn't changed
habeebweeb 4 年之前
父節點
當前提交
ef1dcf7749
共有 1 個文件被更改,包括 5 次插入1 次删除
  1. 5 1
      COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/GUI/Controls/SelectionGrid.cs

+ 5 - 1
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/GUI/Controls/SelectionGrid.cs

@@ -34,7 +34,11 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             {
                 SimpleToggle toggle = new SimpleToggle(items[i], i == SelectedItem);
                 toggle.toggleIndex = i;
-                toggle.ControlEvent += (s, a) => this.SelectedItem = (s as SimpleToggle).toggleIndex;
+                toggle.ControlEvent += (s, a) =>
+                {
+                    int value = (s as SimpleToggle).toggleIndex;
+                    if (value != this.SelectedItem) this.SelectedItem = value;
+                };
                 toggles[i] = toggle;
             }
             return toggles;