RFE: PopMenu onClose Callback

It would be great if we could have an onClose callback with the popMenu. I made a fork of the popMenu a while back that included this feature and I’ve found it pretty useful in a few circumstances. In particular, if I need to highlight/un-highlight a UI element when a context menu is open/closed.

onRollover is called in the same Close method but unfortunately there’s nothing in that callback that can be used to tell the difference between rolling off the window and closing the menu. So there could potentially just be something added to the info of onRollover to solve the issue but I think a separate callback is a cleaner solution.

PopMenuExt.py

Add named arg default None

	def Open(self, items=None, callback=None, callbackDetails=None,
			 highlightedItems=None, disabledItems=None, dividersAfterItems=None,
			 checkedItems=None, subMenuItems=None, autoClose=None,
			 shortcuts=None,
			 rolloverCallback=None, closeCallback=None,
             allowStickySubMenus=None,
			 title=None, scale=None):

Add at line 220:

		if closeCallback:
			self.SetCallback(closeCallback, "onClose")
		else:
			self.SetCallback(None, "onClose")

Add DoCallback in Close method

	def Close(self):
		"""
		Close the menu
		"""
		try:
			self._openDelay.kill()
		except:
			pass
		self._openDelay = None
		if self.IsOpen:
			ext.CallbacksExt.DoCallback('onRollover', self.infoDict(-1))
			ext.CallbacksExt.DoCallback('onClose', self.infoDict())
			self.ownerComp.par.Checkeditems.mode = ParMode.CONSTANT
			self.Window.par.winclose.pulse()
			if self.ParentMenu:
				if not self.ParentMenu.Scaler.panel.focusselect:
					self.ParentMenu.Scaler.setFocus()
				self.ParentMenu = None
			self.TempAdjustX = self.TempAdjustY = 0
		self.callback = None

Drop a popMenu from the palette and look in the docked config comp. There’s a callbacks DAT in there with an onClose callback. Does that not work for ya?

Yep that does work. I was just trying to utilize the built in popMenu in TDResources and not drop an additional tree of popMenus and sub pop menus into the scene.

So it’s not really holding me back from accomplishing my goals but it would be a nice feature to consider adding in the future.