Shortcut to open snap menu

Next
 From:  ttype (STRUBE)
7277.1 
Hi,

I hope I am not bothering (too much) and I admit it is not important (at all), but since the shortcut I found on Petr's site and here on the forum seems to be 7 years old I thought maybe something has changed meanwhile.

To open my snap menu I use this snippet:
code:
var cb = moi.ui.getUIPanel('moi://ui/CommandBar.htm');
moi.ui.showMenu( 'ObjectSnapMenu.htm', cb.document.body.lastChild.lastChild, 2, 0 );

Is it also possible, maybe by firing an UIEvent to open it the same way a mouse click would do? I mean, is there a shortcut that opens it this way:

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

Previous
Next
 From:  Michael Gibson
7277.2 In reply to 7277.1 
Hi Strube, it's possible to do that, the script has to dig into the UI to retrieve a reference to the grid snap button and pass that to showMenu() - the structure of the UI changed from v2 to v3 and so that old script only worked to find the button for v2.

Try this instead for v3:

script: /* Show snap menu */ moi.ui.showMenu( 'ObjectSnapMenu.htm', moi.ui.commandBar.document.getElementsByTagName( 'moi:StateButton' )[2], 2, 0 );

- 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:  ttype (STRUBE)
7277.3 In reply to 7277.2 
Wow, nice, I hadn't been able to find the "moi:xxx" elements either.

But, of course, the same had to be tested for the file menu:
code:
moi.ui.showMenu( 'FileMenu.htm', moi.ui.commandBar.document.getElementsByTagName( 'moi:CommandMenuButton' )[0], 2, 0 );


And it looks somewhat unfinished:


Can I perhaps make it look like this:


What I tried is stuff like this:
code:
var elem = moi.ui.commandBar.document.getElementsByTagName( 'moi:CommandMenuButton' )[0];

var evt = new MouseEvent("click", {
    bubbles: true,
    cancelable: true,
    view: window,
});

elem.dispatchEvent(evt);


But it keeps saying "'MouseEvent' ... is not a constructor.", which seems to be a bug in Qt4 Webkit. (Which also happens for "Event".)

  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
7277.4 In reply to 7277.3 
Hi Strube,

> Can I perhaps make it look like this:

Sorry no I don't think you can get the little arrow thing to be displayed programmatically - it's built into menu launching buttons that when the button enters the hover state it will show that menu launcher arrow thing above it. I don't know if there is any general way to set the hover state from script, it's not quite the same as triggering event handlers. I think it's only something that gets set in response to actual mouse events.

- 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
 From:  ttype (STRUBE)
7277.5 In reply to 7277.4 
Ok, 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
 

Reply to All Reply to All