0

Can rvtypes.MinorModes communicate with each other using events?

Hi support team,

I have two Rv packages (MinorModes) that would ideally be able to communicate with each other. Rather than calling code directly, I was wondering if it would be possible to to a Qt style emit() and have the other package listen to such a signal or event.

Could you point me to the right functions or section in the manual if this is possible?

 

cheers,

Jordan

6 comments

  • 0
    Avatar
    Michael Kessler

    Custom events don't seem to be provided by RV (however, if this is untrue; I'd like to be corrected).  However, from my experience; you could set yourself up with some sort of central qt signal-emitting object that is gotten through via the Qt hierarchy.

    An example of getting at the MainWindow can be found here:
    https://support.shotgunsoftware.com/entries/96056447

    There shouldn't be much stopping you from looking for a QObject you've created in the hierarchy and connecting to a signal it can emit; essentially using that as your central point for communication.  The object would need to be either reliably created first, or be auto-created if it didn't exist so that the first one got it.  This approach requires some stability in your definition of this central object; but that is already somewhat of a requirement if you are connecting to signals; since the signals in-effect will become your public interface.

     

    -Kessler

  • 0
    Avatar
    Jordan Olson

    Thank you Michael, that is helpful.

    I trust Image Engine is doing well.

     

  • 0
    Avatar
    Alan Trombla

    Thanks for chiming in Michael!  That's interesting.

    For the record, Modes can communicate with each other by sending "custom events".  These are basically arbitrary strings / cookies (the event name), that have additional associated strings ("contents" and "sender").   (This is how the various Shotgun packages communicate with each other.)  Docs:

    commands.sendInternalEvent

    sendInternalEvent (string; 
                       string eventName,
                       string contents = nil,
                       string senderName = nil)
    

    Description

    Send an application generated event to the user interface. The event is sent immediately. The event can optionally be sent with a string that is retrievable via the Event.contents() function and a senderName retrievable with the Event.sender() function.

    Cheers,

    Alan 

  • 0
    Avatar
    Jordan Olson

    Thank you Alan!

    That should be precisely what I need.

  • 0
    Avatar
    Jon Morley

    The Mode that wants to receive your custom event would just bind an event handler to the event in the bindings list in the event's init() call, just like other events.

    Hope that helps.

    Below is Michael's sample code.

    Thanks,
    Jon

  • 0
    Avatar
    Jordan Olson

    Thanks Jon,

    Yes this works like a charm. By binding it to a custom string name I have the modes communicating with each other effectively.

Please sign in to leave a comment.