Python GUI: mouse wheel


#1

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 ?


#2

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


(Steve Baer) #3

You can somewhat work around this by using

Rhino.UI.Dialogs.ShowSemiModal(myform)

instead of
myform.ShowDialog()


#4

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

Thanks Mark and Steve.


#5

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.


#6

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