Eto - Ignore Mouse On Form/Disable Interaction?

Hello,

Is there a way to visually show a form while having it not “listen” for mouse events or prevent mouse interaction with the form. (I know this sounds a bit counter intuitive)

I have a form that is supposed to close on MouseUp and works overall unless the user mouse is hovering on the form itself when MouseUp occurs, if this happens, the form stays and does not close until I instantiate the form again (since I run a function to close any active form prior to creating a new one)

Mouse Up Code:

    def OnMouseUp(self, e):
        if e.Button == System.Windows.Forms.MouseButtons.Middle:
            if self.mouse_moved:
                self.original_position = None
                if self.form:
                    selected_index = self.form.selected_button_index
                    # Close the form first
                    self.form.Close()
                    self.form = None
                    if selected_index is not None:
                        # Execute the corresponding Rhino command
                        commands = ["Floor", "Wall", "Door", "Window", "Electrical", "Plumbing", "Object", "Room"]
                        Rhino.RhinoApp.WriteLine("Running {} tool...".format(commands[selected_index]))
                        if selected_index < len(commands):
                            Rhino.RhinoApp.RunScript(commands[selected_index], False)
                        else:
                            Rhino.RhinoApp.WriteLine("No command found for index {}.".format(selected_index))
            elif self.form:
                # If mouse hasn't moved, close the form
                self.form.Close()
                self.form = None

Thank you all for your help!

In Eto, if you set e.Handled = true on your MouseDown, it should then capture the mouse so that you can get the MouseUp. You should also set the form’s ShowActivated = false so it doesn’t steal focus.

Although I’m not sure about how that works on Windows Forms, as it appears that code above is using e.Button == System.Windows.Forms.MouseButtons.Middle

Hope this helps!

1 Like

Awesome, thanks @curtisw I was only using WindowForms mouse because I couldn’t figure out how to get the Eto mouse events working.

I’ll try your suggestions and report back.

Thank you for the help!