0

rv menu toggle doesn't work

Hello!

I'm having trouble getting the toggle feature working on menu items corresponding to an rv packages. I've explained a simple repro case below and I would appreciate if someone could help identify what I'm missing.

1. Contents of PACKAGE file -
modes:
- file: browser.py
  menu: 'MyMenu/Browser'
  shortcut: control f1
  load: lazy

2. Contents of browser.py

import rv.rvtypes

class Browser(rv.rvtypes.MinorMode):
    def __init__(self):
    super(Browser, self).__init__()
    self.init("my_test_browser", None, None, None)

    def activate(self):
        print "activating"
        return

    def deactivate(self):
        print "deactivating"
        return

def createMode():
    return Browser()

When I open RV, I can see the Browser menu under MyMenu on the menubar and when I press Control+F1, the activate() gets called and it prints "activate" as expected. All good so far! Now when I press Control+F1 again, instead of calling deactivate() and toggling the menu OFF, it again calls "activate". No matter how many times I use the hot key, it always calls activate(). Another thing I notice is that there is no check-mark on the menu that I would see when its active and not see when its inactive. Basically the toggle isn't working.

Then I removed activate() and deactivate() methods from browser.py and tried the hotkey again, and the toggle works! I can see the check-mark go ON and OFF suggesting its actually toggling.

So I think for some reason the activate() and deactivate() methods disable the toggle feature.

Can someone explain what's happening here? Am I missing something?

Thanks in advance!
Venu.

2 comments

  • Avatar
    (Michael) Kessler Official comment

    Venu,

    It appears that you are blocking the execution from reaching the parent class.

    If you check out the pyside_example.py that ships with RV, you'll see that the activate method calls the MinorMode's activate so that it can do the regular processing required.

        def activate(self):

            rv.rvtypes.MinorMode.activate(self)

            self.dialog.show()

     

    And similarly the deactivate does the same thing:

        def deactivate(self):

            rv.rvtypes.MinorMode.deactivate(self)

            self.dialog.hide()


    Try adding those to your activate/deactivate.

  • 0
    Avatar
    Venu Krishnamurthy

    Awesome Michael!! Thanks for the quick response. That makes sense. I tried it and it works!!

    Thanks again!
    Venu.

Please sign in to leave a comment.