UIX Samples at Github - should they work?

I tried this one and It does nothing. Both zipped and on folder

https://github.com/M-Files/MFilesSamplesAndLibraries/tree/master/Samples/UIX%20Applications/AlterContextMenuDependingOnSelectedObject

I'm looking for a way to hide items from second mouse click context menu and that sample should get me going if it would do something. Latest M-Files Online.

Cheers

PJ

  • Hi PJ,

    I have just installed this to my local vault and it seems to work.  If I right-click on a single object then I get a command listed entitled "My command".  If I select multiple objects, or I right-click on a view, then the command is not there.

    Note that this project only targets the M-Files desktop, not anything else.

    Did you install the application and then log out (not just close the window) and log in again?

    Regards,

    Craig.

  • Strange enough, it does work on my local vault as well. I didn't even get a prompt for application to the environment where I try to get it to work. So Samples work.

  • This one hides Create menu from context menu

    shellFrame.Commands.SetCommandState( BuiltinCommand_NewObject, CommandLocation_ContextMenu, CommandState_Hidden );

    Is there a way to hide elements under Create menu like BuiltinCommand_NewObject.141 that would hide creation of object with ID 141 ?

  • I don't believe so.  One thing you could do is react to the "OnBuiltInCommand" event (M-Files UI Extensibility Framework - OnBuiltinCommand Event) and check the parameter provided.  This gives you the object type ID (e.g. 141).  If you return false from this event handler then it effectively cancels the operation.

    So it doesn't hide the option, but it does help stop users using it.

    There may be some non-code options (e.g. to stop the creation of objects of this type via the M-Files Admin), but I assume that you've exhausted those...?

  • OK, so you cannot hide those. Thanks for help again!

  • I think I found a bug.

    shellFrame.Commands.SetCommandState( BuiltinCommand_NewObject, CommandLocation_ContextMenu, CommandState_Hidden );

    This hides menu from second mouse click that I thought was "Context menu"?

    Above command hides creation of new objects from Top row Create button as in picture too. I would only like hide commands from Second mouse click while that menu is the same as the one under ALT Create where it can be while users don't know that.

  • Hi PJ,

    What M-Files version are you using?

    Regards,

    Craig.

  • I found tracker item 153177 which talks about CommandLocation_ContextMenu not working correctly.  Apparently this was fixed in 20.1 but, having just tested in 20.11, I see some odd behaviour as well.  `CommandLocation_ContextMenu` seems to also affect the "Create" button in the top pane, which isn't intuitive.

    I'm going to open another tracker item, relate it to this, and see what PD say.  It may be that the top bar and context menu are, unfortunately, intrinsically linked.

  • I have created tracker item 161323.