Semi Modal Focus Switching?


Recently I’ve been designing more UIs using windows forms and IronPython. The basic method is: make a form with a panel situated on it, add some controls to the panel, and display the dialogue using Rhino.UI.Dialogs.ShowSemiModal. The UI provides the link into some code that can generate geometry, etc.

My question is; it seems like while the dialog is being displayed, it is not possible to interact with the main window in the normal ways, which i gather is an issue of the main window not being in focus. Is there a way to switch focus to the main window when I need to? Or does the concept semi-modal dialog prevent this altogether? I am able to move the camera with my space-mouse, but the normal mouse camera movements are different (Ctrl right-click to zoom, etc), and selecting/interacting with objects is impossible altogther.

If the UI controls i needed were simply buttons, I would consider just putting them into a toolbar, but I need the flexibility of forms to get text boxes that react to other controls, etc. This is not possible with a user-defined toolbar, right? But if I could “dock” the form and use that to keep focus in the main window, that would be perfect.


Not sure if it’s quite the solution you’re looking for, but you might want to investigate this sample:

It shows how to create a docked UserControl that behaves like the Layers/Properties/Help etc. panels, which I think should allow you to interact with the viewports as normal.

(Steve Baer) #3

This is the purpose of semi-modal. If you want your dialog to just be a floating dialog with no blocking of anything that you can do in Rhino, then you will want to use a non-modal dialog. This is done by simply calling the Show function on your dialog. Note, that this is much more difficult to code against since your dialog continues to run beyond completion of your python script.



Could you explain a little bit why it’s “more difficult to code against”? I have tried this, and while my script finishes running, and the dialog remains, all my buttons/stuff still works, so the code is still in memory apparently. Can you give a short example of when using non-modal would be problematic?