()
| 324 | } |
| 325 | |
| 326 | func (cb *ComboBox) attachModel() { |
| 327 | itemsResetHandler := func() { |
| 328 | cb.resetItems() |
| 329 | } |
| 330 | cb.itemsResetHandlerHandle = cb.model.ItemsReset().Attach(itemsResetHandler) |
| 331 | |
| 332 | itemChangedHandler := func(index int) { |
| 333 | if win.CB_ERR == cb.SendMessage(win.CB_DELETESTRING, uintptr(index), 0) { |
| 334 | newError("SendMessage(CB_DELETESTRING)") |
| 335 | } |
| 336 | |
| 337 | cb.insertItemAt(index) |
| 338 | |
| 339 | cb.SetCurrentIndex(cb.prevCurIndex) |
| 340 | } |
| 341 | cb.itemChangedHandlerHandle = cb.model.ItemChanged().Attach(itemChangedHandler) |
| 342 | |
| 343 | cb.itemsInsertedHandlerHandle = cb.model.ItemsInserted().Attach(func(from, to int) { |
| 344 | for i := from; i <= to; i++ { |
| 345 | cb.insertItemAt(i) |
| 346 | } |
| 347 | }) |
| 348 | |
| 349 | cb.itemsRemovedHandlerHandle = cb.model.ItemsRemoved().Attach(func(from, to int) { |
| 350 | for i := to; i >= from; i-- { |
| 351 | cb.removeItem(i) |
| 352 | } |
| 353 | }) |
| 354 | } |
| 355 | |
| 356 | func (cb *ComboBox) detachModel() { |
| 357 | cb.model.ItemsReset().Detach(cb.itemsResetHandlerHandle) |
no test coverage detected