MCPcopy
hub / github.com/lxn/walk / onRemovedWidget

Method onRemovedWidget

splitter.go:552–608  ·  view source on GitHub ↗
(index int, widget Widget)

Source from the content-addressed store, hash-verified

550}
551
552func (s *Splitter) onRemovedWidget(index int, widget Widget) (err error) {
553 defer func() {
554 if err != nil {
555 return
556 }
557
558 s.updateMarginsForFocusEffect()
559 }()
560
561 _, isHandle := widget.(*splitterHandle)
562 if !s.removing && isHandle && s.children.Len()%2 == 1 {
563 return newError("cannot remove splitter handle")
564 }
565
566 if !isHandle {
567 sl := s.layout.(*splitterLayout)
568 widget.AsWidgetBase().Property("Visible").Changed().Detach(sl.hwnd2Item[widget.Handle()].visibleChangedHandle)
569 }
570
571 if !isHandle && s.children.Len() > 1 {
572 defer func() {
573 if err != nil {
574 return
575 }
576
577 var handleIndex int
578 if index == 0 {
579 handleIndex = 0
580 } else {
581 handleIndex = index - 1
582 }
583
584 s.removing = true
585 handle := s.children.items[handleIndex].window.(*splitterHandle)
586
587 if err = handle.SetParent(nil); err == nil {
588 sl := s.layout.(*splitterLayout)
589
590 for _, item := range sl.hwnd2Item {
591 item.oldExplicitSize = 0
592 item.keepSize = false
593 }
594
595 sl.resetNeeded = true
596 s.RequestLayout()
597
598 handle.Dispose()
599 }
600
601 s.removing = false
602 }()
603 }
604
605 err = s.ContainerBase.onRemovedWidget(index, widget)
606
607 return
608}
609

Callers

nothing calls this directly

Calls 12

newErrorFunction · 0.85
PropertyMethod · 0.80
ChangedMethod · 0.65
AsWidgetBaseMethod · 0.65
HandleMethod · 0.65
SetParentMethod · 0.65
RequestLayoutMethod · 0.65
DisposeMethod · 0.65
onRemovedWidgetMethod · 0.65
LenMethod · 0.45
DetachMethod · 0.45

Tested by

no test coverage detected