Example #1
0
func (s *ScrollBar) MouseDown(ev gxui.MouseEvent) {
	if s.barRect.Contains(ev.Point) {
		initialOffset := ev.Point.Sub(s.barRect.Min)
		var mms, mus gxui.EventSubscription
		mms = ev.Window.OnMouseMove(func(we gxui.MouseEvent) {
			p := gxui.WindowToChild(we.WindowPoint, s.outer)
			s.SetScrollPosition(s.rangeAt(p.Sub(initialOffset)))
		})
		mus = ev.Window.OnMouseUp(func(we gxui.MouseEvent) {
			mms.Unlisten()
			mus.Unlisten()
		})
	}
	s.InputEventHandler.MouseDown(ev)
}
Example #2
0
// InputEventHandler overrides
func (b *SplitterBar) MouseDown(e gxui.MouseEvent) {
	b.isDragging = true
	b.onDragStart.Fire(e)
	var mms, mus gxui.EventSubscription
	mms = e.Window.OnMouseMove(func(we gxui.MouseEvent) {
		if b.onDrag != nil {
			b.onDrag(we.WindowPoint)
		}
	})
	mus = e.Window.OnMouseUp(func(we gxui.MouseEvent) {
		mms.Unlisten()
		mus.Unlisten()
		b.isDragging = false
		b.onDragEnd.Fire(we)
	})

	b.InputEventHandler.MouseDown(e)
}
Example #3
0
func beginTabDragging(holder gxui.PanelHolder, panel gxui.Control, name string, window gxui.Window) {
	var mms, mos gxui.EventSubscription
	mms = window.OnMouseMove(func(ev gxui.MouseEvent) {
		for _, c := range gxui.TopControlsUnder(ev.WindowPoint, ev.Window) {
			if over, ok := c.C.(gxui.PanelHolder); ok {
				insertAt := insertIndex(over, c.P)
				if over == holder {
					if insertAt > over.PanelIndex(panel) {
						insertAt--
					}
				}
				holder.RemovePanel(panel)
				holder = over
				holder.AddPanelAt(panel, name, insertAt)
				holder.Select(insertAt)
			}
		}
	})
	mos = window.OnMouseUp(func(gxui.MouseEvent) {
		mms.Unlisten()
		mos.Unlisten()
	})
}