Callback when export dialog open

Hi, I want to run a callback each time a particular export window opens using vanilla.

thanks

I am looking for exactly the same thing. Rainer says callbacks are not the way to go, but I don’t believe him :grin:

1 Like

Oh that’s disappointing
then I’ll have to read the entire init.py file and figure out
I will share the solution here when I’m done
thank you @SCarewe

You can observe when any window becomes key window.
https://developer.apple.com/documentation/appkit/nswindowdidbecomekeynotification?language=objc

center = NSNotificationCenter.defaultCenter()
center.addObserver_selector_name_object_(self, "windowStatusDidChange:". :NSWindowDidBecomeKeyNotification, None)

I’m sorry to keep asking much @GeorgSeifert
but 4 hours I couldn’t make it work because I’m not familiar with Apple documentation

What do you want to do in the actual export window? Maybe a callback is not the right way.

I’m trying to call an action each time user opens my exporting plugin tab

What is it what you like to do? It seems hat you like to update the dialog with info from the current font. You could overwrite the setter for self.font:

	def setFont_(self, font):
		self._font = font
		# setup stuff with the new font

it is called before the dialog is shown.

1 Like

it seems little confusing
i’m trying to get the dialog open notification part

In other way:
(call a function each time the export dialog opened )
so when the user click export i got notification that the user is navigated to the export window

What for? What do you want to do with the information?

Thank you!!! This is exactly what I was looking for all the time.

when i got notified that the user had opened my plugin ( export window) then make things ready, Like showing a preview of the final result that user going to export
or scale the current text on the current tab preview

I do not see how checking the window status would help with that. Better access the font for drawing the way Georg described, and make your drawings with it etc.

The setFont_() method is basically the callback you are looking for. It is invoked just before the window is shown.