MoI discussion forum
MoI discussion forum

Full Version: Check if context window is open in script?

From: local306
2 Oct 2019   [#1]
Is there a way via scripting to check whether a context window is open i.e.) if I'm drawing a circle and it's asking for the radius or diameter.

Reason being is that I would like to map each of the orthogonal views to my numpad 1, 3, and 7 values similar to other 3D apps. Problem is that if I go to punch in a value when a context window is open using my numpad, the app will jump to one of my ortho views should I have used one.

I'd like to check whether a context window is open, and if not, then proceed with setting the appropriate view. Otherwise, don't interfere with numpad input for quickly setting values when using tools.
From: Michael Gibson
2 Oct 2019   [#2] In reply to [#1]
Hi local306, in version 4 there is a property: moi.command. currentCommandName which will have the name of the currently running command if there is one.

So something like:

if ( moi.command.currentCommandName == '' )
{
/// Do something only if no command is running
}

Also if you hit the Tab key it will put keyboard focus into any input field that's in the command context UI, so you if you press the tab key before you type your numbers that should also work with your current setup.

If the input field has focus your numpad keys should go to it instead of being triggered as a shortcut key.

- Michael
From: local306
3 Oct 2019   [#3] In reply to [#2]
Thank you kindly for the response Michael.

I had noticed while experimenting that the tab key set the focus like you said — I'm just too lazy to input another keystroke at times :P That's great news that it seems like there is a solution for this coming out with v4 though.

On the side, as a new user I am having a lot of fun with MoI! As a former design engineer familiar with SolidWorks, MoI has been pleasant to work with. Its speed and simplicity makes it very enjoyable. Still learning the ropes with it, but hopefully soon I'll have something to show the community :D
From: Michael Gibson
3 Oct 2019   [#4] In reply to [#3]
Hi local306, I'm glad you are liking MoI!

You can get the current v4 beta which has that property in it from http://moi3d.com/beta.htm .

Then you would need to incorporate that into your shortcut key. But hmm there will be a remaining problem that you would be to make the shortcut key do nothing when some command UI was showing but there isn't any way for the shortcut key to tell MoI to continue with the regular behavior as if no shortcut key was set.

The intended behavior is that if you have set a number key as a shortcut key that will then be used for the shortcut instead of sending keystrokes to input fields. If you don't want that then the normal thing is to not set a number key as a shortcut.

- Michael