core/window: implement a new dropfile event, currently used only on macosx.

This commit is contained in:
Mathieu Virbel 2012-03-02 00:48:32 +01:00
parent 6c1430d3c2
commit 4952db3b22
2 changed files with 21 additions and 0 deletions

View File

@ -195,6 +195,8 @@ class WindowBase(EventDispatcher):
Fired when a key is down
`on_key_up`: key, scancode, unicode
Fired when a key is up
`on_dropfile`: str
Fired when a file is dropped on the application
'''
__instance = None
@ -367,6 +369,7 @@ class WindowBase(EventDispatcher):
self.register_event_type('on_keyboard')
self.register_event_type('on_key_down')
self.register_event_type('on_key_up')
self.register_event_type('on_dropfile')
super(WindowBase, self).__init__()
@ -711,6 +714,19 @@ class WindowBase(EventDispatcher):
'''Event called when a key is up (same arguments as on_keyboard)'''
pass
def on_dropfile(self, filename):
'''Event called when a file is dropped on the application.
.. warning::
This event is actually used only on MacOSX with a patched version of
pygame. But this will be a place for a further evolution (ios,
android etc.)
.. versionadded:: 1.1.2
'''
pass
def configure_keyboards(self):
# Configure how to provide keyboards (virtual or not)

View File

@ -273,6 +273,11 @@ class WindowPygame(WindowBase):
elif event.type == pygame.ACTIVEEVENT:
pass
# drop file (pygame patch needed)
elif event.type == pygame.USEREVENT and hasattr(pygame,
'USEREVENT_DROPFILE') and event.code == pygame.USEREVENT_DROPFILE:
self.dispatch('on_dropfile', event.filename)
'''
# unhandled event !
else: