Python GUI: mouse wheel

Hi
using GDI+ with Iron Python I noticed that when the Form is shown, I cannot zoom into Rhino using the mouse wheel (Pan by right button works fine)
For example Mark Meier’s Circle UI Example.py shows this behaviour.
Is this to be expected ?

Yes this is because the UI Form has the “focus” so the mouse wheel is captured by the UI and not the Rhino viewport. So you have to use Ctrl+right-click and drag to zoom.

Mark

You can somewhat work around this by using

Rhino.UI.Dialogs.ShowSemiModal(myform)

instead of
myform.ShowDialog()

This happens using Rhino.UI.Dialogs.ShowSemiModal()
Ctrl-right-click is fine (I did not remember that …)

Thanks Mark and Steve.

Hello,

Is there any way to switch the focus from the Form to the Viewport when clicked on the respective interfaces? The workaround for Zoom is fine (Ctrl + Right click), but am unable to select objects in the viewport when the Form is displayed.

Thanks all.

What we do when we need to select in the Rhino viewport when the UI is up is hide the form, execute one of the rs methods to select, then when that returns show the form again. This has worked well for us. This a code snippet:

form.Hide()

rs.GetObjects(…)

form.Show()

You often need to reset the Rhino command prompt and cursor after this is done as they are not reset automatically when using a GUI. So we do this:

rs.Prompt(None)
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default

Mark

Hi @stevebaer, i am using above method in V6 and the mouse wheel does not zoom. The focus is on Rhino. Is this something which should work in V6 ?

_
c.

I’m not exactly sure; I’ll have to punt that off to @JohnM to answer.

When you say the focus is on Rhino do you mean you clicked in a Rhino view and the dialog box is not active? Can you pan?

Hi @JohnM, the dialog is active of course, but the focus is on Rhino after clicking in a viewport to navigate. I can pan and rotate, i can zoom only with CTRL + RMB but the mouse wheel does not zoom.
_
c.

@clement Does it work when running the ReduceMesh command? I tested using a few of our .NET Eto based command dialogs and it work here. If so, can you provide me with a sample script so I can try to reproduce this?

Hi @JohnM, i am using a WinForm not an Eto based form. Using ReduceMesh the mouse wheel works as expected. An example WinForm is attached below.

ShowSemiModal.py (2.2 KB)

_
c.

@clement Thanks, Eto uses WPF not WinForms so I’m guessing this has something specific to do with how WinForms is handled. I will test using your script.

@clement I did some testing and it worked on the first two computers I tried but not on the third. After poking around we figured out there is a Windows setting which can affect this, you need to enable the Windows “Settings/Mouse/Scroll inactive windows when I hover over them” settings, see the attached screen shot.

1 Like

Hi @JohnM,

thank you for the investigation. Unfortunately i use Win7 where i do not have this setting.

_
c.