Strange behavior for a UI displayed by CommandMenuButton or moi.ui.showMenu

Next
 From:  mkdm
7904.1 
Hi Michael,

i'm trying to write a UI plugin that must contain also an inputbox placed in a menu displayed by a CommandMenuButton.

Just two questions...

1) How to force a Dialog or a Menu, opened via moi.ui.createDialog(...) or moi.ui.showMenu(...), to focus the inputbox, once displayed ?
The classic "<the element>.focus()" doesn't work.

2) If i show the plugin interface via a CommandMenuButton, or even programmatically via the moi.ui.showMenu(...),
i get a strange behavior that happens when i start to write something inside the inputbox.
After every key press, the inputbox loses the focus and i must click again in it to continue to write.
And furthermore, after every key press in the inputbox, the menu blinks for a fraction of second, as if it's recreates itself .

This behaviors not happens if i show the same plugin inside a dialog, created using moi.ui.createDialog(...).

Thank you for all and have a nice day!

Marco.

EDITED: 30 Mar 2016 by MKDM

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
7904.2 In reply to 7904.1 
Hi Marco, can you post your current code or ideally make a simplified example that is not behaving properly so I can run it over here and test it?

For focus, any of the moi Input controls I think should automatically get focus on a flyout menu when the user starts typing stuff in. One example in the regular UI is the Grid flyout, that pops up from the Grid Snap button on the bottom. If you open that flyout and then start typing numbers, keyboard focus automatically goes to the
first numeric input control on that menu. This does not happen by default with a dialog though unless it is marked as a "command dialog" (which is why it works on the mesh export dialog for example) but currently setting that property on the dilaog is not exposed to script.

I'm not sure that I'll be able to help you with the weird behavior one without actually being able to reproduce it over here.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  mkdm
7904.3 In reply to 7904.2 
Hi Michael,

Good day and thank you for your quick reply, as usual.

First of all i'm glad to tell you that, after many months spent to test and try this software,
this morning i finally purchased a commercial version of Moi v3!

From a medium skilled software developer to a bigger software developer, hats off to you !!

I sense that the source code you wrote is very elegant and massive object oriented,
with a big focus on the user experience.
I'm an old Amiga user's and i must say that from the golden Amiga's age, i did not see a piece of software
funny and smart like Moi.

Anyway...
My intention is to use it in bundle with my commercial version of Rhino V5.
I'd like to know better how Moi and Rhino can share the files saved in the .3dm format.
I first made a little test to see if the materials stored in a .3dm Rhino file,
are maintained and saved back from Moi, but unfortunately this test not gave me the desired results....
The material assigned to objects where lost after the save made in Moi.
I'm doing something wrong ?
Second point....i saw that Moi's .3dm file is the V4 format and when i save it back from Rhino in the V5 format,
any subsequent save from Moi doesn't work. The file is not saved anymore.


But....returning to my previous post....

I'm trying to write two plugins that will works together : a command search plugin and a global history command list.
At the moment i'm not able to post a simplified version of these files, 'cause i'm a little busy at work.
As soon as i can i will do it.

Anyway, just to better clarify what i asked, i'm getting this two main problems :

1) I have a dialog opened via moi.ui.createDialog(...) containing a standard html input box,
and a standard html table.
The user writes something into the input box and the table is filled up with all the commands and scripts whose names matches the search criteria.
I used the standard "onkeyup" input box event (for some reason with the "onkeydown", doesen't work).

The problems is that once the dialog is opened, the focus is not acquired by the input box, and the user is forced to manually click inside it to
start to write something.
And this slow down the streamline of the process.
Finally when user presses "enter" or click on the desired command in the table, i exec the command and close the dialog,
so the focus return to the Moi's main window.

2) If i show the same plugin via the moi.ui.showMenu(...), what happens is that when i start to write something inside the inputbox,
after every key press, the inputbox loses the focus and i must click again in it to continue to write.

I hope you can help me with this behaviors, 'cause i read many times the Moi's API unofficial documentation (http://moi.maxsm.net/api/)
but i was not able to find what i was looking for.

Thank you for all and have a nice day!

Marco.
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
7904.4 In reply to 7904.3 
Hi Marco, thanks for your order! I also got started on 3D graphics using Amiga computers, they were a lot of fun!


> I first made a little test to see if the materials stored in a .3dm Rhino file,
> are maintained and saved back from Moi, but unfortunately this test not gave
> me the desired results....
> The material assigned to objects where lost after the save made in Moi.

Can you please send me the 3DM model file you used for your test? I will take a look at it and see what I can do to improve this in the future.

MoI does make an effort to preserve Rhino data for objects that you do not modify but there may be some areas where that is not being handled correctly, or maybe doesn't work properly with particular Rhino SR versions.

If you can give me the file you tested with so I can repeat your test over here, I could then give you some more information on it.


> Second point....i saw that Moi's .3dm file is the V4 format and when i save it back
> from Rhino in the V5 format, any subsequent save from Moi doesn't work. The file
> is not saved anymore.

I'm sorry I'm not understanding this part - you mean you have a model in MoI that won't save out at all after it has been loaded into MoI? Can you please send me the 3DM file that you are seeing this with so I can try to repeat the problem over here?


> 1) I have a dialog opened via moi.ui.createDialog(...) containing a standard html input box,
> and a standard html table. The user writes something into the input box and the table is filled
> up with all the commands and scripts whose names matches the search criteria.
> I used the standard "onkeyup" input box event (for some reason with the "onkeydown", doesen't work).

Instead of using the plain HTML <input> element try using the MoI-specific <moi:TextInput> element, the MoI-specific one should probably behave better for you since it is registered with MoI's keyboard input system while the standard one will not be.

If that doesn't help, please send me the code that you're trying to use so I can repeat your problem over here and try some things to solve it.

It may be possible that there isn't a solution because you'd be fighting against the built in focus handling which is not based around a dialog workflow, I vaguely remember there may be something in place that specifically ignores dialogs (unless they're marked as a "command dialog" as mentioned in a previous message) since the MoI UI is designed to try and use the dedicated command options area in the side pane to put in most controls rather than popping up dialogs.

Anyway I could most likely give you better information if I could repeat what you are describing over here.


> 2) If i show the same plugin via the moi.ui.showMenu(...), what happens is that
> when i start to write something inside the inputbox, after every key press, the
> inputbox loses the focus and i must click again in it to continue to write.

This would probably behave better using the <moi:TextInput> control rather than plain <input>.


Hope that helps some - if you can give me repeatable examples instead of just descriptions that would probably help a lot, like when you say "I tested with a 3DM" file, send the actual file, and when you say "I used moi.ui.createDialog()", send the actual code for triggering the dialog and the HTML code for the dialog too.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  mkdm
7904.5 In reply to 7904.4 
Hi Michael,

Thank you very much for your deep answer.

As recommended by you, i made another and more precise test and here i present you the result.
My Rhino version is : Version 5 SR12 64-bit 5.12.50810.13095, 10/08/2015

I have attached the 3dm files and the screen captures of all the test stages.

This are the steps of the test i made :

1) Step 001
Create a simple file in Moi that contain only 1 sphere, named "sphere1" and assigned to a material named "moi_sphere",
then saved it in the file "step_001_saved_from_moi.3dm".
See the attached files "step_001_saved_from_moi.3dm" and "step_001.PNG"

2) Step 002
Loaded in Rhino V5 the file "step_001_saved_from_moi.3dm" and assigned a marble material to the sphere.
After that i first wanted to overwrite the file, and Rhino showed me the popup window captured in the "step_002_B.PNG" file.
The popup said : "This model contains information that cannot be saved in the Rhino 4.0 file format.......Save as 4.0 file.....Save as 5.0 file....."
Anyway, in order to maintain separated the steps of this test, i saved as 5.0 in the new file "step_002_saved_from_rhino.3dm"
See the attached files "step_002_saved_from_rhino.3dm" and "step_002_B.PNG"

3) Step 003
Loaded in Moi the file "step_002_saved_from_rhino.3dm" and simply added a new object.
A cylinder assigned to a material named "moi_cylinder".
I didn't touch the sphere.
Save all to the new file "step_003_saved_from_moi.3dm".
See the attached files "step_003_saved_from_moi.3dm" and "step_003.PNG"

4) Step 004
Loaded in Rhino V5 the file "step_003_saved_from_moi.3dm" and duplicated the cylinder made in Moi.
The marble material assigned to the sphere was always there.
I didn't touch the sphere.
Save all to the new file "step_004_saved_from_rhino.3dm".
See the attached files "step_004_saved_from_rhino.3dm" and "step_004.PNG"

5) Step 005
Loaded in Moi the file "step_004_saved_from_rhino.3dm" and this time simply moved the sphere object.
That's the crucial point!
Save all to the new file "step_005_saved_from_moi.3dm".
See the attached files "step_005_saved_from_moi.3dm" and "step_005.PNG"

6) Step 006
Loaded in Rhino V5 the file "step_005_saved_from_moi.3dm" and....
THE SPHERE OBJECT HAD NO MORE THE RHINO MATERIAL ..
See the attached file "step_006.PNG"

So....is it all correct ? Is this the normal behavior of the entire process ?
I ask this 'cause i want to know a good workflow method to follow in order to use both the software, Rhino and Moi.
Just to model both in Moi and Rhino, save back and forth the files, and then render all inside Rhino/Thea Render.

And...about the other question i made, regarding the writing of the search/history commands plugin,
i'll will try to use the <moi:TextInput> instead the standard html <input>, as recommended by you.

Compatibly with my work commitments, i hope that soon i can post some decent lines of code.

Meantime...thank's again for your support and...good night!

Marco.

Image Attachments:
Size: 407.6 KB, Downloaded: 22 times, Dimensions: 1137x650px
Size: 463.4 KB, Downloaded: 18 times, Dimensions: 1201x691px
Size: 153.5 KB, Downloaded: 19 times, Dimensions: 724x402px
Size: 424.6 KB, Downloaded: 13 times, Dimensions: 1137x656px
Size: 469.8 KB, Downloaded: 16 times, Dimensions: 1209x687px
Size: 432.2 KB, Downloaded: 13 times, Dimensions: 1136x652px
Size: 266.7 KB, Downloaded: 9 times, Dimensions: 1182x604px
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  Michael Gibson
7904.6 In reply to 7904.5 
Hi Marco, thanks for the much more detailed steps, that helps a lot!


> So....is it all correct ? Is this the normal behavior of the entire process ?

Yes, that's currently the normal behavior - MoI goes through some effort to preserve object attributes of Rhino-specific things that MoI itself does not use, but that will only happen for objects that have not been edited in MoI. When you do the step of moving the sphere, that's a type of edit and it's basically the equivalent of the original sphere being destroyed and a new sphere with different coordinates being created. With the object being changed and having a different id, MoI will no longer find the original Rhino attributes that were assigned to the original sphere and so you get the result you see here.


> I ask this 'cause i want to know a good workflow method to follow in order to use both the
> software, Rhino and Moi. Just to model both in Moi and Rhino, save back and forth the files,
> and then render all inside Rhino/Thea Render.

Most of the time I'd recommend moving in the direction of creating stuff in MoI and moving it most often in one direction from MoI to Rhino.

One thing that might work better is to assign your material by layer rather than having it assigned as an override to the individual object like you have done here. To do that in Rhino in the object material properties have that set to "Assign material by: Layer", and then set your material on the layer. Then as long as you don't modify the Styles list in MoI (which map to Layers in Rhino), the layer properties should round trip back to Rhino I think. Then I think you can create new objects in MoI, the materials will still work because the default for a new object is to have materials by layer.


You previously mentioned this:

> Second point....i saw that Moi's .3dm file is the V4 format and when i save it
> back from Rhino in the V5 format, any subsequent save from Moi doesn't
> work. The file is not saved anymore.

Here were you talking about the dialog that pops up, or something different? Or did I miss it in your steps above?

When you start a fresh 3DM file in MoI, it will default to writing Rhino v4 format 3DM files. But when you open a v5 3DM file originally created by Rhino v5 into MoI, MoI will remember it was a v5 3DM file that was opened and will then write a v5 file when you save it out again.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All