Organizing scripts in customui

Next
 From:  Barry-H
12127.1 
**Title: MoI V5 CustomUI — Positioning category submenus correctly**

Hi,

I'm using MoI 3D V5 with CustomUI and have created a `ScriptsFull.menu.htm` menu that groups custom scripts into categories based on filename prefixes, such as `CRV_`, `SRF_`, `SOL_`, `SEL_` and `UTL_`.

The main Full Scripts flyout opens correctly to the left of its button, which is on the bottom toolbar.

However, when I select a category such as Curves, its submenu opens at the bottom-right of the screen rather than being positioned correctly alongside the main menu.

I'm currently calling:

```js
moi.ui.showMenu(
"moi://appdata/customui/" + file,
moi.ui.commandBar.CommandBarCustomUI,
1,
0
);
```

I've also tried `0, 0` and `3, 0`. These haven't resolved the positioning issue.

The original `Scripts.menu.htm` works as expected. Is there a way to anchor the category submenu to the Full Scripts menu item itself, or otherwise control its horizontal and vertical position?

I'd appreciate any guidance on the correct `showMenu()` arguments or the appropriate UI element to use as the anchor.

Thanks!
  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
12127.2 In reply to 12127.1 
Hi Barry,

re:
> The main Full Scripts flyout opens correctly to the left of its button, which is on the bottom toolbar.

Can you please show a screenshot of what this looks like?


> However, when I select a category such as Curves, its submenu opens at the bottom-right of the
> screen rather than being positioned correctly alongside the main menu.

Also a screenshot of this too please.

Thanks, - 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:  Barry-H
12127.3 In reply to 12127.2 
Hi Michael,
the attached photo's show the issue.
The left hand script button opens the complete list of scripts as normal.
The right hand button opens new layout in a restricted width ok but when selecting a sub menu it opens it bottom right of screen.
However all the scripts that are not in the sub menu's that are not listed in dropdown there is an option to open them and they get displayed correctly.
Thanks
Barry
Ps: here are the htm's of the new fullscript and sub solid menu

EDITED: 13 Oct by BARRY-H


Image Attachments:
Size: 170.6 KB, Downloaded: 26 times, Dimensions: 684x456px
Size: 99 KB, Downloaded: 24 times, Dimensions: 684x456px
Size: 100.4 KB, Downloaded: 18 times, Dimensions: 684x456px
Size: 473.7 KB, Downloaded: 13 times, Dimensions: 2736x1824px
  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:  Barry-H
12127.4 In reply to 12127.2 
Hi Michael,
Have found away to do it using a control panel.
Many thanks
Barry
  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
12127.5 In reply to 12127.3 
Hi Barry, thanks for posting the screenshots and your script code.

Ok, so the sub menu opening on the bottom right of the screen is from passing moi.ui.commandBar.CommandBarCustomUI as the parent element of the menu.

The menu will show being connected to the screen rectangle of the parent element. The element you are passing, CommandBarCustomUI, is the container of all the custom buttons in the bottom command bar. You usually want to pass in the button element that is being clicked on. That will be easier to get if you use an onclick="" event handler on the <moi:MenuItem> instead of having a command="" attribute with script inside it instead of a command name.

For an onclick="" event handler you will be able to use the 'this' keyword to refer to the element that was clicked on.

Then there's an additional tricky thing which is that by default most elements will automatically dismiss the flyout they are inside when they are clicked. That will interfere with launching a sub menu coming off of another flyout menu like you want here. So you'll need to put a style property dismissFlyout:false on the MenuItem also.

So try this for making your sub-menu links:

document.write('<moi:MenuItem style="dismissFlyout:false" onclick="moi.ui.showMenu(\'moi://appdata/customui/ScriptsCategory_SOL.menu.htm\', this, 1, 0);">Solids ></moi:MenuItem>');


The 3rd and 4th arguments to moi.ui.showMenu control how the menu will attach to the parent element's rectangle.

The 3rd argument is for LaunchSide which can be 0, 1, 2, 3 The 4th argument is for LaunchDir which can be 0 or 1.

The menu connection will go like this:

LaunchSide 0 Flyout has connector at its top, expanding to the right if LaunchDir == 0 or expanding to left if LaunchDir != 0

LaunchSide 1 Flyout has a connector on its left, expanding down if LaunchDir == 0 or up if LaunchDir != 0

LaunchSide 2 Flyout has a connector on its bottom, expanding right or left

LaunchSide 3 Flyout has a connector on its right, expanding down or up.

So if you pass in LaunchSide 1, LaunchDir 0 it will make the menu with the connector on the menu's left (so to the right of the parent element), expanding down, like this example in the Options dialog under Snaps:



Hope this helps! - Michael
Attachments:

  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