none
MouseLeave event not firing when mouse leaves plugin container in Mac Firefox

    Question

  • For Silverlight apps which are running inside of Firefox on Mac, the MouseLeave event does not fire when you mouse off the Silverlight container. It still fires normally inside the Silverlight container. Mac Safari/Chrome, Windows Firefox/IE/Chrome all fire this event normally.

    I'm using the latest version of Firefox (10.0.2) and Silverlight (5.0.61118.0); on Mac OS X 10.6.8.

    To reproduce this error, create a basic Silverlight web project and set up some MouseEnter and MouseLeave events.  

    MainPage.xaml:

    <UserControl x:Class="MacFFSLMouseout.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        d:DesignHeight="300" d:DesignWidth="400">
    
        <Grid x:Name="LayoutRoot" Background="Blue" MouseEnter="MainPage_MouseEnter" MouseLeave="MainPage_MouseLeave">
            <TextBlock x:Name="text"  Foreground="White" Text="Default"></TextBlock>
        </Grid>
    </UserControl>

    MainPage.xaml.cs:

    namespace MacFFSLMouseout
    {
        public partial class MainPage : UserControl
        {
            public MainPage()
            {
                InitializeComponent();
            }
    
            
            void MainPage_MouseEnter(object sender, MouseEventArgs e)
            {
                this.text.Text = "Mouse entered";
            }
    
            void MainPage_MouseLeave(object sender, MouseEventArgs e)
            {
                this.text.Text = "Mouse left";
            }
        }
    }
    

    CSS on host page is the default, recommended CSS:

     html, body {
    	    height: 100%;
    	    overflow: auto;
        }
        body {
    	    padding: 0;
    	    margin: 0;
        }
        #silverlightControlHost {
    	    height: 100%;
    	    text-align:center;
        }
    

    Is my Firefox merely behaving strangely? Any suggestions for workarounds? I think my next step will be adding a JavaScript mouseoff event handler and calling a script method in Silverlight, but I'd rather not because it involves some icky workarounds in my Silverlight app.

    EDIT: I added a MouseMove handler:

    this.MouseMove += (s, e) => 
        this.text.Text = String.Format("Mouse moved to: ({0}, {1})", 
            e.GetPosition(this).X, e.GetPosition(this).Y);

    On my Mac Firefox, it's reporting that the mouse is at (5, 5) (edit 2: most of the time) when I move it off the plugin container. The browsers which are working all report (0, 0).  Here's a demo test page.

    Wednesday, February 29, 2012 9:34 AM

All replies

  • http://boardreader.com/thread/MouseLeave_event_not_firing_when_mouse_l_oz7hbX5d4u.html
    Thursday, November 01, 2012 8:52 AM