Undoes the strategy of the commit 646aabd;

that commit replaces a feature, this adds one.

Brief update of the module documentation.

Bugfix for F11 key binding.
Bugfix for F12 key binding.
This commit is contained in:
Alexandre Magno 2013-04-23 19:28:48 -03:00
parent 68a870c849
commit cb3b635501
1 changed files with 10 additions and 6 deletions

View File

@ -5,8 +5,11 @@ Keybinding
This module force the mapping of some keys to functions: This module force the mapping of some keys to functions:
* F11: Rotate the Window from 0, 90, 180, 270 * F11: Rotate the Window from 0, 90, 180, 270
* Shift + F11: Switches between portrait and landscape on PC
* F12: Take a screenshot * F12: Take a screenshot
Note: this don't work if the application requires keyboard before.
''' '''
from kivy.utils import platform from kivy.utils import platform
@ -14,13 +17,14 @@ from kivy.utils import platform
__all__ = ('start', 'stop') __all__ = ('start', 'stop')
def _on_keyboard_handler(instance, key, scancode, codepoint, modifier): def _on_keyboard_handler(instance, key, scancode, codepoint, modifiers):
if key == 293: # F12 if key == 293 and modifiers == []: # F12
instance.screenshot() instance.screenshot()
elif key == 292: # F11 elif key == 292 and modifiers == []: # F11
if not platform() in ('win', 'linux', 'macosx'):
instance.rotation += 90 instance.rotation += 90
else: elif key == 292 and modifiers == ['shift']: # Shift + F11
if platform() in ('win', 'linux', 'macosx'):
instance.rotation = 0
w, h = instance.size w, h = instance.size
w, h = h, w w, h = h, w
instance.size = (w, h) instance.size = (w, h)