leonsal 8 лет назад
Родитель
Сommit
2be7d64753
4 измененных файлов с 11 добавлено и 6 удалено
  1. 1 3
      gui/button.go
  2. 2 1
      gui/list.go
  3. 0 2
      gui/root.go
  4. 8 0
      gui/tree.go

+ 1 - 3
gui/button.go

@@ -65,6 +65,7 @@ func NewButton(text string) *Button {
 	b.Panel.Subscribe(OnKeyUp, b.onKey)
 	b.Panel.Subscribe(OnMouseUp, b.onMouse)
 	b.Panel.Subscribe(OnMouseDown, b.onMouse)
+	b.Panel.Subscribe(OnCursor, b.onCursor)
 	b.Panel.Subscribe(OnCursorEnter, b.onCursor)
 	b.Panel.Subscribe(OnCursorLeave, b.onCursor)
 	b.Panel.Subscribe(OnEnable, func(name string, ev interface{}) { b.update() })
@@ -131,13 +132,10 @@ func (b *Button) onCursor(evname string, ev interface{}) {
 	case OnCursorEnter:
 		b.mouseOver = true
 		b.update()
-		b.root.StopPropagation(Stop3D)
 	case OnCursorLeave:
 		b.pressed = false
 		b.mouseOver = false
 		b.update()
-	default:
-		return
 	}
 	b.root.StopPropagation(StopAll)
 }

+ 2 - 1
gui/list.go

@@ -364,6 +364,7 @@ func (li *List) highlighted() (pos int) {
 func (li *List) onMouseEvent(evname string, ev interface{}) {
 
 	li.root.SetKeyFocus(li)
+	li.root.StopPropagation(StopAll)
 }
 
 // onKeyEvent receives subscribed key events for the list
@@ -478,7 +479,7 @@ func (litem *ListItem) onMouse(evname string, ev interface{}) {
 	}
 }
 
-// onCursor receives cursor enter events over the list item
+// onCursor receives subscribed cursor events over the list item
 func (litem *ListItem) onCursor(evname string, ev interface{}) {
 
 	if litem.list.dropdown {

+ 0 - 2
gui/root.go

@@ -296,11 +296,9 @@ func (r *Root) sendPanels(x, y float32, evname string, ev interface{}) {
 			}
 			// Mouse button event
 		} else {
-			log.Error("Dispatch event:%s to %T z:%v", evname, ipan, pan.Position().Z)
 			pan.Dispatch(evname, ev)
 		}
 		if (r.stopPropagation & StopGUI) != 0 {
-			log.Error("stopPropagation:%v", r.stopPropagation)
 			break
 		}
 	}

+ 8 - 0
gui/tree.go

@@ -60,6 +60,7 @@ func (t *Tree) Initialize(width, height float32) {
 	t.SetStyles(&StyleDefault.Tree)
 	t.List.Subscribe(OnKeyDown, t.onKey)
 	t.List.Subscribe(OnKeyUp, t.onKey)
+	t.List.Subscribe(OnCursor, t.onCursor)
 }
 
 // SetStyles set the tree styles overriding the default style
@@ -174,6 +175,13 @@ func (t *Tree) FindChild(child IPanel) (*TreeNode, int) {
 	return nil, -1
 }
 
+// onCursor receives subscribed cursor events over the tree
+func (t *Tree) onCursor(evname string, ev interface{}) {
+
+	// Do not propagate any cursor events
+	t.root.StopPropagation(StopAll)
+}
+
 // onKey receives key down events for the embedded list
 func (t *Tree) onKey(evname string, ev interface{}) {