mojo canvas mouseEntered



  • I'm learning more about mojo canvas and am having trouble getting mouseEntered/mouseExited to work. Below is a little test script adding a box to the glyph window. mouseDown works. mouseEntered/mouseExited do not. Anyone know whatimdoingwrong?

    from vanilla import *
    from mojo.events import addObserver, removeObserver
    from mojo.canvas import CanvasGroup
    from mojo.drawingTools import rect
    
    debug = True
    
    class observerTest(object):
    
        def __init__(self):
            if debug == True:
                self.w = Window((150, 50), "debug only")
                self.w.bind("close", self.windowClose)
                self.w.open()
            self.setupStuff()
    
        def setupStuff(self):
            addObserver(self, "doStuff", "glyphWindowWillOpen")
    
        def windowClose(self, sender):
            removeObserver(self, "glyphWindowWillOpen")
    
        def doStuff(self, notification):
            self.window = notification["window"]
            self.offsidesUI = CanvasGroup((0, 0, 100, 100), delegate=self)
            self.window.addGlyphEditorSubview(self.offsidesUI)
    
        def draw(self):
            rect(0, 0, 100, 100)
        def mouseDown(self, event):
            print('mouseDown')
        def mouseEntered(self, event):
            print('mouseEntered')
        def opaque(self):
            return False
        def shouldDrawBackground(self):
            return False
    
    observerTest()
    

  • admin

    a tracking area is needed to catch mouseEntered and mouseExited events – this will be added automatically in the next beta. The default will be the bounds of the view. Canvas objects can overwrite this and add their own tracking rects with a new delegate callback: updateTrackingAreas.



  • Thanks for the explanation. I'll give this another shot when the next beta drops.