Пример #1
0
    def test_get_set_mod_state(self):
        initial = keyboard.get_mod_state()
        for state in(keycode.KMOD_NUM | keycode.KMOD_CAPS | keycode.KMOD_MODE,
                      keycode.KMOD_NUM | keycode.KMOD_CAPS,
                      keycode.KMOD_CAPS):
            keyboard.set_mod_state(state)
            self.assertEqual(keyboard.get_mod_state(), state)

        state = keycode.KMOD_NUM
        keyboard.set_mod_state(state)
        self.assertEqual(keyboard.get_mod_state(), state)

        keyboard.set_mod_state(initial)
        self.assertEqual(keyboard.get_mod_state(), initial)
Пример #2
0
    def test_pygame2_sdl_keyboard_set_mod_state(self):

        # __doc__ (as of 2009-05-13) for pygame2.sdl.keyboard.set_mod_state:

        # set_mod_state (mod) -> None
        # 
        # Sets the current modifier key state.
        # 
        # Sets the current modifier key state. mod has to be a bitwise OR'd
        # combination of the KMOD_* flags as they are specified in the
        # constants.
        self.assertEqual (keyboard.get_mod_state (), 0)
        kstate = constants.KMOD_LALT|constants.KMOD_NUM
        keyboard.set_mod_state (kstate)
        self.assertEqual (keyboard.get_mod_state (), kstate)
        keyboard.set_mod_state (constants.KMOD_CAPS)
        self.assertEqual (keyboard.get_mod_state (), constants.KMOD_CAPS)
        keyboard.set_mod_state (kstate)
        self.assertEqual (keyboard.get_mod_state (), kstate)
Пример #3
0
    def test_pygame2_sdl_keyboard_get_mod_state(self):

        # __doc__ (as of 2009-05-13) for pygame2.sdl.keyboard.get_mod_state:

        # get_mod_state () -> state
        # 
        # Returns the current state of the modifier keys (CTRL, ALT, etc.).
        # 
        # Returns a single integer representing a bitmask of all the
        # modifier keys being held. Using bitwise operators you can test
        # if specific shift keys are pressed, the state of the capslock
        # button, and more.  The bitmask will consist of the various
        # KMOD_* flags as specified in the constants.
        self.assertEqual (keyboard.get_mod_state (), 0)
        kstate = constants.KMOD_LALT|constants.KMOD_NUM
        keyboard.set_mod_state (kstate)
        self.assertEqual (keyboard.get_mod_state (), kstate)
        keyboard.set_mod_state (constants.KMOD_CAPS)
        self.assertEqual (keyboard.get_mod_state (), constants.KMOD_CAPS)
        keyboard.set_mod_state (kstate)
        self.assertEqual (keyboard.get_mod_state (), kstate)