0

RV Remove custom Menu from Main Menu without deactivate MinorMode

Hi again,

Do you know if it is possible to remove/hide a menu entry from the main menu bar in RV without having the MinorMode associated deactivated ?

To clarify, and related to my other post, I have a MinorMode that opens a widget, that I'd like to keep activated at all time. And when the widget goes shown, it would put its menu in the main menu bar, but when hidden the menu would be hidden as well from the main menu bar.

I tried the defineModeMenu("myMode", nil) method in my overridden deactivate() method but the custom menu stays in the main menu bar. Same with the setMenu().
I've seen there's a function buildMainMenu() in rvui, that maybe would be a hint to force the redraw of the main menu without my custom one, but to keep the other custom menus, I have to give them as args to this function and I have no idea how to get those.

Any idea ?

Thank you!

5 条评论

  • 0
    Avatar
    (Michael) Kessler

    Hi Caroline,

     

    You could use the defineMenuMode, but like you mention, to override the whole menu; you need the prior items.  You can get around some of this by setting or unsetting the strict flag, but you still need to know the prior state.

    You can hold on to a reference to your original menu before setting it, which would let you recompose it later.

     

    However, what is the reason you'd like your mode to remain active all the time?  If you want your mode to activate/deactivate and hide/show the menus associated with the activation/deactivation then the model you are trying to achieve is the standard model.  You can further get some value out of that with a delay load of your package.

     

    If you are wanting to keep your mode active all the time to be able to receive events, is it possible to write this as two minor modes?  One to handle the transient state, and one to handle the persistent state?

     

    Thanks,

    -Kessler

  • 0
    Avatar
    Caroline Beyne

    Hi Kessler,

     

    Thank you for your answer.
    I did tried the strict flag = true when calling defineModeMenu() but surely I missed something because it had no effect neither.

    I will try the 2 minor modes trick, I think that will fix both of my issues. I will let you know the result.

    Btw, any idea how to call a MinorMode from another one before I look for it in the doc?

     

    Thanks again,

    Caro

  • 0
    Avatar
    (Michael) Kessler

    Ideally your modes would actually send internal signals and bind to those.  Check out:

    commands.sendInternalEvent

     

    You can make your own events that your other package can respond to.  That way you are also not creating a direct dependency on the two code blocks and allowing yourself a way to have multiple plugins respond to a single event.

  • 0
    Avatar
    Caroline Beyne

    Hi,

    Thank you for your answer. I had a look at the sendInternalEvent(), that looks cool. I actually already had a working version and I used a singleton on top of that and it's working the way I want.

    Anyways, thanks again for pointing the 2 MinorModes trick, it's working perfectly.

  • 0
    Avatar
    (Michael) Kessler

    Excellent!!

    If you ever want to show it off, I love seeing what people make.  Shared data structures (such as a singleton) or Qt signals are of course other options that should work well.

    Thanks,

    -Kessler

请先登录再写评论。