(action *Action, visibleChanged bool)
| 225 | } |
| 226 | |
| 227 | func (m *Menu) insertAction(action *Action, visibleChanged bool) (err error) { |
| 228 | m.handleDefaultState(action) |
| 229 | |
| 230 | if !visibleChanged { |
| 231 | action.addChangedHandler(m) |
| 232 | defer func() { |
| 233 | if err != nil { |
| 234 | action.removeChangedHandler(m) |
| 235 | } |
| 236 | }() |
| 237 | } |
| 238 | |
| 239 | if !action.Visible() { |
| 240 | return |
| 241 | } |
| 242 | |
| 243 | index := m.actions.indexInObserver(action) |
| 244 | |
| 245 | var mii win.MENUITEMINFO |
| 246 | |
| 247 | m.initMenuItemInfoFromAction(&mii, action) |
| 248 | |
| 249 | if !win.InsertMenuItem(m.hMenu, uint32(index), true, &mii) { |
| 250 | return newError("InsertMenuItem failed") |
| 251 | } |
| 252 | |
| 253 | if action.Default() { |
| 254 | win.SetMenuDefaultItem(m.hMenu, uint32(m.actions.indexInObserver(action)), true) |
| 255 | } |
| 256 | |
| 257 | menu := action.menu |
| 258 | if menu != nil { |
| 259 | menu.window = m.window |
| 260 | } |
| 261 | |
| 262 | m.ensureMenuBarRedrawn() |
| 263 | |
| 264 | return |
| 265 | } |
| 266 | |
| 267 | func (m *Menu) removeAction(action *Action, visibleChanged bool) error { |
| 268 | index := m.actions.indexInObserver(action) |
no test coverage detected