Right Click Contextual Menu on a Button?

  • Hi,

    Is there a way I can have flyout/contextual menu when I right click button?
    Currently, the default menu pops up when I do so.
    You can see the illustration of the problem here:

    Is there a direct way of doing this? That is a parameter of the AddButton element that allows such feature. There seems to be none in the documentation, but still want to confirm.

    There is also a working code of RMB Contextual Menu on this thread. The problem is the RMB Contextual Menu is the same in all areas of the GeDialog.
    I was thinking of just isolating the function in the area of button (i.e. indirect way).
    If so, how do I determine the X,Y area of button relative to the dialog? Although of course, I'd prefer the direct way. hehehe

    Thanks for looking at my problem

  • Hi @bentraje,

    GeDialog.GetItemDim Can be used to retrieve x/y and size/height of a gadget. Of course, the dialog needs to be open, otherwise, you will get weird results.

    So if you modify the code provided in Disable default Right-Click Menu of IsPositionInGuiArea with the next one is working as expected.

        def IsPositionOnGadget(self, gadgetId, x, y):
            # Be sure that the windows is opened,
            # in our case since we call it in BFM_INTERACTSTART it's ok
            buttonData = self.GetItemDim(gadgetId)
            if not buttonData["x"] < x < buttonData["x"] + buttonData["w"]:
                return False
            if not buttonData["y"] < y < buttonData["y"] + buttonData["h"]:
                return False
            return True


  • @m_adam

    Works as expected! Thanks again for the sample code, makes everything clear.

Log in to reply