python类MOUSEMOTION的实例源码

title_scene.py 文件源码 项目:PyCut 作者: FOSSRIT 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def ProcessInput(self, events, pressed_keys):
        for event in events:
            if event.type == pygame.KEYDOWN and event.key == pygame.K_RETURN:
                # Move to the next scene when the user pressed Enter
                pass

            if event.type == pygame.MOUSEBUTTONDOWN:
                self.start_button.isClicked(event)
                self.help_button.isClicked(event)
                self.difficulty_button.isClicked(event)

            if event.type == pygame.MOUSEBUTTONUP:
                self.start_button.isClicked(event)
                self.help_button.isClicked(event)
                self.difficulty_button.isClicked(event)

            if event.type == pygame.MOUSEMOTION:
                self.start_button.isHovered(event)
                self.help_button.isHovered(event)
                self.difficulty_button.isHovered(event)
help_scene.py 文件源码 项目:PyCut 作者: FOSSRIT 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def ProcessInput(self, events, pressed_keys):
        for event in events:
            if event.type == pygame.KEYDOWN and event.key == pygame.K_RETURN:
                # Move to the next scene when the user pressed Enter
                pass

            if event.type == pygame.MOUSEBUTTONDOWN:
                for button in self.buttons:
                    button.isClicked(event)

            if event.type == pygame.MOUSEBUTTONUP:
                for button in self.buttons:
                    button.isClicked(event)

            if event.type == pygame.MOUSEMOTION:
                for button in self.buttons:
                    button.isHovered(event)
difficulty_scene.py 文件源码 项目:PyCut 作者: FOSSRIT 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def ProcessInput(self, events, pressed_keys):
        """
        Process Input from user
        Inherited from SceneBase
                Args:   self
                        events - list of pygame events
                        pressed_keys
        """

        for event in events:
            if event.type == pygame.KEYDOWN and event.key == pygame.K_RETURN:
                # Move to the next scene when the user pressed Enter
                pass

            if event.type == pygame.MOUSEBUTTONDOWN:
                self.easy_button.isClicked(event)
                self.adv_button.isClicked(event)

            if event.type == pygame.MOUSEBUTTONUP:
                self.easy_button.isClicked(event)
                self.adv_button.isClicked(event)

            if event.type == pygame.MOUSEMOTION:
                self.easy_button.isHovered(event)
                self.adv_button.isHovered(event)
event.py 文件源码 项目:PyCut 作者: FOSSRIT 项目源码 文件源码 阅读 35 收藏 0 点赞 0 评论 0
def _mousemove_cb(self, widget, event):
        # From http://www.learningpython.com/2006/07/25/writing-a-custom-widget-using-pygtk/
        # if this is a hint, then let's get all the necessary 
        # information, if not it's all we need.
        if event.is_hint:
            win, x, y, state = event.window.get_device_position(event.device)
        else:
            x = event.x
            y = event.y
            state = event.get_state()

        rel = (x - self.__mouse_pos[0], y - self.__mouse_pos[1])
        self.__mouse_pos = (x, y)

        self.__button_state = [
            state & Gdk.ModifierType.BUTTON1_MASK and 1 or 0,
            state & Gdk.ModifierType.BUTTON2_MASK and 1 or 0,
            state & Gdk.ModifierType.BUTTON3_MASK and 1 or 0,
        ]

        evt = pygame.event.Event(pygame.MOUSEMOTION,
                                 pos=self.__mouse_pos, rel=rel, buttons=self.__button_state)
        self._post(evt)
        return True
tetris.py 文件源码 项目:Traptris 作者: JesperDramsch 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def __init__(self):
        pygame.init()
        pygame.key.set_repeat(250,25)
        self.width = cell_size*(2*cols+2)
        self.height = cell_size*rows
        self.rlim = cell_size*cols

        self.default_font =  pygame.font.Font(
            pygame.font.get_default_font(), 12)

        self.screen = pygame.display.set_mode((self.width, self.height))
        pygame.event.set_blocked(pygame.MOUSEMOTION) # We do not need
                                                     # mouse movement
                                                     # events, so we
                                                     # block them.
        self.next_stone = tetris_shapes[rand(len(tetris_shapes))]

        self.init_game()
        pygame.mixer.init()
        pygame.mixer.music.load(file)
        pygame.mixer.music.play(loops=-1)
game004.py 文件源码 项目:eduActiv8 作者: imiolek-ireneusz 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def handle(self, event):
        gd.BoardGame.handle(self, event)  # send event handling up
        if self.show_msg == False:
            if event.type == pygame.KEYDOWN and event.key != pygame.K_RETURN:
                lhv = len(self.home_square.value)
                self.changed_since_check = True
                if event.key == pygame.K_BACKSPACE:
                    if lhv > 0:
                        self.home_square.value = self.home_square.value[0:lhv - 1]
                elif not self.board.grid[4][18]:
                    char = event.unicode
                    if len(char) > 0 and lhv < 2 and char in self.digits:
                        self.home_square.value += char
                self.home_square.update_me = True
                self.mainloop.redraw_needed[0] = True
            elif event.type == pygame.MOUSEMOTION and self.drag:
                if self.board.grid[4][18]:
                    self.home_square.value = ""
                    self.home_square.update_me = True
            elif event.type == pygame.MOUSEBUTTONUP:
                for each in self.board.units:
                    if each.is_door is True:
                        self.board.all_sprites_list.move_to_front(each)
game035.py 文件源码 项目:eduActiv8 作者: imiolek-ireneusz 项目源码 文件源码 阅读 73 收藏 0 点赞 0 评论 0
def handle(self, event):
        gd.BoardGame.handle(self, event)  # send event handling up
        if self.show_msg == False:
            if event.type == pygame.KEYDOWN and event.key != pygame.K_RETURN:
                lhv = len(self.home_square.value)
                self.changed_since_check = True
                if event.key == pygame.K_BACKSPACE:
                    if lhv > 0:
                        self.home_square.value = self.home_square.value[0:lhv - 1]
                elif not self.board.grid[4][18]:
                    char = event.unicode
                    if len(char) > 0 and char in self.digits:
                        self.home_square.value = char
                self.home_square.update_me = True
                self.mainloop.redraw_needed[0] = True
            elif event.type == pygame.MOUSEMOTION and self.drag:
                if self.board.grid[4][18]:
                    self.home_square.value = ""
                    self.home_square.update_me = True
            elif event.type == pygame.MOUSEBUTTONUP:
                for each in self.board.units:
                    if each.is_door is True:
                        self.board.all_sprites_list.move_to_front(each)
game034.py 文件源码 项目:eduActiv8 作者: imiolek-ireneusz 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def handle(self, event):
        gd.BoardGame.handle(self, event)  # send event handling up
        if self.show_msg == False:
            if event.type == pygame.KEYDOWN and event.key != pygame.K_RETURN:
                lhv = len(self.home_square.value)
                self.changed_since_check = True
                if event.key == pygame.K_BACKSPACE:
                    if lhv > 0:
                        self.home_square.value = self.home_square.value[0:lhv - 1]
                elif not self.board.grid[4][16]:
                    char = event.unicode
                    if len(char) > 0 and char in self.digits:
                        self.home_square.value = char
                self.home_square.update_me = True
                self.mainloop.redraw_needed[0] = True
            elif event.type == pygame.MOUSEMOTION and self.drag:
                if self.board.grid[4][16]:
                    self.home_square.value = ""
                    self.home_square.update_me = True
            elif event.type == pygame.MOUSEBUTTONUP:
                for each in self.board.units:
                    if each.is_door is True:
                        self.board.all_sprites_list.move_to_front(each)
menu.py 文件源码 项目:eduActiv8 作者: imiolek-ireneusz 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def handle(self, event):
        # TO DO
        if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
            self.mouse_dn = True
        elif event.type == pygame.MOUSEBUTTONUP and event.button == 1 and self.mouse_dn:
            self.menu.active_cat = self.cat_id
            if self.menu.active_cat_o is not None:
                if self.menu.active_cat_o != self:
                    self.menu.active_cat_o.deactivate()
            self.activate()

            self.menu.mainloop.redraw_needed[1] = True
            self.menu.mainloop.redraw_needed[2] = True

        elif event.type == pygame.MOUSEMOTION:
            self.on_mouse_over()
menu.py 文件源码 项目:eduActiv8 作者: imiolek-ireneusz 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def handle(self, event):
        # TO DO
        if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
            self.mouse_dn = True
        elif event.type == pygame.MOUSEBUTTONUP and event.button == 1 and self.mouse_dn:
            pass
            """
            self.menu.active_cat = self.cat_id
            #self.tab_l_scroll = (self.scroll_l // self.scroll_step)
            if self.menu.mainloop.config.settings["sounds"]:
                s3.play()
            self.menu.mainloop.redraw_needed[1] = True
            self.menu.mainloop.redraw_needed[2] = True
            """
        elif event.type == pygame.MOUSEMOTION:
            self.on_mouse_over()
slider.py 文件源码 项目:Peppy 作者: project-owner 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def handle_event(self, event):
        """ Slider event handler

        :param event: event to handle
        """
        if not self.visible:
            return
        mouse_events = [pygame.MOUSEBUTTONUP, pygame.MOUSEBUTTONDOWN, pygame.MOUSEMOTION]        
        if getattr(event, "source", None):
            self.event_source_local = False
        else:
            self.event_source_local = True        

        if event.type in mouse_events:
            pos = event.pos        
            if not self.bounding_box.collidepoint(pos):
                return            
            self.mouse_action(event)
        elif event.type == USER_EVENT_TYPE:
            self.user_event_action(event)
slider.py 文件源码 项目:Peppy 作者: project-owner 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def mouse_action(self, event):
        """ Mouse event handler

        :param event: event to handle
        """
        pos = event.pos

        if self.selected and not(self.last_knob_position < pos[0] < self.last_knob_position + self.knob_width and pos[1] > self.bounding_box.y) and event.type != pygame.KEYUP:
            return

        button_press_simulation = getattr(event, "p", None)

        if event.type == pygame.MOUSEBUTTONUP and self.clicked:
            self.release_action(pos)                
        elif event.type == pygame.MOUSEBUTTONDOWN and self.bounding_box.collidepoint(pos):
            self.press_action()            
        elif event.type == pygame.MOUSEMOTION and (pygame.mouse.get_pressed()[0] or button_press_simulation) and self.bounding_box.collidepoint(pos) and self.clicked:
            self.motion_action(pos)
requesthandler.py 文件源码 项目:Peppy 作者: project-owner 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def handle_command(self, d):
        """ Handles commands sent from web client 

        :param d: command object
        """

        if d["command"] == "init":
            json_data = self.screen_to_json()
            web_socket.send_message(json_data)
        elif d["command"] == "mouse":
            a = {}
            a["pos"] = (d["x"], d["y"])
            a["button"] = d["b"]
            event = None
            if d["d"] == 0:
                event = pygame.event.Event(pygame.MOUSEBUTTONDOWN, **a)
            elif d["d"] == 1:
                event = pygame.event.Event(pygame.MOUSEBUTTONUP, **a)
            elif d["d"] == 2:
                event = pygame.event.Event(pygame.MOUSEMOTION, **a)
                event.p = True
            event.source = "browser"
            thread = Thread(target=pygame.event.post, args=[event])
            thread.start()
event.py 文件源码 项目:HFOSSFinal 作者: AlanLeeson 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def _mousemove_cb(self, widget, event):
        # From http://www.learningpython.com/2006/07/25/writing-a-custom-widget-using-pygtk/
        # if this is a hint, then let's get all the necessary 
        # information, if not it's all we need.
        if event.is_hint:
            win, x, y, state = event.window.get_device_position(event.device)
        else:
            x = event.x
            y = event.y
            state = event.get_state()

        rel = (x - self.__mouse_pos[0], y - self.__mouse_pos[1])
        self.__mouse_pos = (x, y)

        self.__button_state = [
            state & Gdk.ModifierType.BUTTON1_MASK and 1 or 0,
            state & Gdk.ModifierType.BUTTON2_MASK and 1 or 0,
            state & Gdk.ModifierType.BUTTON3_MASK and 1 or 0,
        ]

        evt = pygame.event.Event(pygame.MOUSEMOTION,
                                 pos=self.__mouse_pos, rel=rel, buttons=self.__button_state)
        self._post(evt)
        return True
gui.py 文件源码 项目:PyBot 作者: Pentabyteman 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def update(self, event):
        try:
            if not self.contains(*event.pos):
                if not self.focussed:
                    return
        except AttributeError:
            return
        if event.type == pygame.MOUSEMOTION:
            if self.contains(*event.pos):
                self.focussed = True
                self.mouse_entered()
            else:
                self.focussed = False
                self.mouse_left()
            self.mouse_moved(event)
        elif event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
            if self.contains(*event.pos):
                self.clicked(event)
event.py 文件源码 项目:math-hurdler 作者: craigcabrey 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def _mousemove_cb(self, widget, event):
        # From http://www.learningpython.com/2006/07/25/writing-a-custom-widget-using-pygtk/
        # if this is a hint, then let's get all the necessary 
        # information, if not it's all we need.
        if event.is_hint:
            win, x, y, state = event.window.get_device_position(event.device)
        else:
            x = event.x
            y = event.y
            state = event.get_state()

        rel = (x - self.__mouse_pos[0], y - self.__mouse_pos[1])
        self.__mouse_pos = (x, y)

        self.__button_state = [
            state & Gdk.ModifierType.BUTTON1_MASK and 1 or 0,
            state & Gdk.ModifierType.BUTTON2_MASK and 1 or 0,
            state & Gdk.ModifierType.BUTTON3_MASK and 1 or 0,
        ]

        evt = pygame.event.Event(pygame.MOUSEMOTION,
                                 pos=self.__mouse_pos, rel=rel, buttons=self.__button_state)
        self._post(evt)
        return True
rigeditor.py 文件源码 项目:renpy-shader 作者: bitsawer 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def handleEvents(self):
        self.mouse = self.get(MOUSE)

        for event, pos in self.context.events:
            self.mouse = pos

            handled = self.mode.handleEvent((event, pos))
            if not handled:
                if event.type == pygame.MOUSEBUTTONDOWN:
                    self.handleMouseDown(event, pos)
                elif event.type == pygame.MOUSEMOTION:
                    self.handleMouseMotion(pos)
                elif event.type == pygame.MOUSEBUTTONUP:
                    self.handleMouseUp(pos)

        if self.mouse:
            self.set(MOUSE, self.mouse)
tetrisCopy.py 文件源码 项目:AAAI 作者: vignesh0710 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __init__(self):
        pygame.init()
        pygame.key.set_repeat(250,25)
        self.width = cell_size*(cols+6)
        self.height = cell_size*rows
        self.rlim = cell_size*cols
        self.bground_grid = [[ 8 if x%2==y%2 else 0 for x in xrange(cols)] for y in xrange(rows)]

        self.default_font =  pygame.font.Font(
            pygame.font.get_default_font(), 12)

        self.screen = pygame.display.set_mode((self.width, self.height))
        pygame.event.set_blocked(pygame.MOUSEMOTION) # We do not need
                                                     # mouse movement
                                                     # events, so we
                                                     # block them.
        self.next_stone = tetris_shapes[rand(len(tetris_shapes))]
        self.init_game()
tetris.py 文件源码 项目:AAAI 作者: vignesh0710 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __init__(self):
        pygame.init()
        pygame.key.set_repeat(250,25)
        self.width = cell_size*(cols+6)
        self.height = cell_size*rows
        self.rlim = cell_size*cols
        self.bground_grid = [[ 8 if x%2==y%2 else 0 for x in xrange(cols)] for y in xrange(rows)]

        self.default_font =  pygame.font.Font(
            pygame.font.get_default_font(), 12)

        self.screen = pygame.display.set_mode((self.width, self.height))
        pygame.event.set_blocked(pygame.MOUSEMOTION) # We do not need
                                                     # mouse movement
                                                     # events, so we
                                                     # block them.
        self.next_stone = tetris_shapes[rand(len(tetris_shapes))]
        self.init_game()
MainMenuNew.py 文件源码 项目:opseilen 作者: Baal221 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def Update(self, events):
        for event in events:
            if event.type == pygame.MOUSEMOTION:
                if self.Rect.collidepoint(event.pos):                    
                    self.Text = (pygame.font.Font(None, 40)).render(self.DefaultText, 1, (255, 190, 0))            
                else:
                    self.Text = (pygame.font.Font(None, 40)).render(self.DefaultText, 1, (130, 130, 130))
            elif event.type == pygame.MOUSEBUTTONDOWN:
                if self.Rect.collidepoint(event.pos):                    
                    return self.Action()
        return self
game_scene.py 文件源码 项目:PyCut 作者: FOSSRIT 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def ProcessInput(self, events, pressed_keys):
        """
        Process input from user
        Inherits from SceneBase
                Args:   self
                        events - pygame events
                        pressed_keys
        """

        for event in events:
            if event.type == pygame.KEYDOWN and event.key == pygame.K_RETURN:
                # Move to the next scene when the user pressed Enter
                pass

            if event.type == pygame.MOUSEBUTTONDOWN:
                for button in self.buttons:
                    button.isClicked(event)
                if self.leveling_up:
                    self.continue_button.isClicked(event)

            if event.type == pygame.MOUSEBUTTONUP:
                for button in self.buttons:
                    button.isClicked(event)
                if self.leveling_up:
                    self.continue_button.isClicked(event)

            if event.type == pygame.MOUSEMOTION:
                #for button in self.buttons:
                #    button.isHovered(event)
                if self.leveling_up:
                    self.continue_button.isHovered(event)
universe.py 文件源码 项目:oficina2017 作者: helioh2 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def big_bang(inic, tela,
             quando_tick=lambda e: e, \
             frequencia=28, \
             desenhar=lambda e: pg.Surface((0,0)), \
             quando_tecla=lambda e, k: e, \
             quando_mouse=lambda e, x, y, ev: e, \
             parar_quando=lambda e: False):

    pg.init()
    estado = inic
    clock = pg.time.Clock()


    while True:

        pg.display.flip()

        if parar_quando(estado):
            print(estado)
            sys.exit(0)

        for event in pg.event.get():
            if event.type == pg.QUIT:
                print(estado)
                sys.exit(0)

            if event.type == pg.KEYDOWN:
                estado = quando_tecla(estado, event.key)

            elif event.type in [pg.MOUSEBUTTONDOWN, pg.MOUSEBUTTONUP, pg.MOUSEMOTION]:
                x, y = pg.mouse.get_pos()
                estado = quando_mouse(estado, x, y, event.type)

        estado = quando_tick(estado)

        tela.fill(COR_BRANCO)
        desenhar(estado)

        clock.tick(frequencia)
nodes.py 文件源码 项目:wargame 作者: maximinus 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def __init__(self, text, signal, align=Align.NONE):
        # make a label of the text - but we only want the image
        label = GuiLabel(text, (0, 0, 0), (214, 214, 214)).image
        # get the contents to render themselves
        border = Resources.configs.get(self.border_config)
        image = add_border(label, border, Resources.get_image(border.image))
        rect = pygame.Rect(0, 0, image.get_width(), image.get_height())
        super().__init__(rect, image, align, False)
        self.messages = [pygame.MOUSEMOTION, pygame.MOUSEBUTTONUP, pygame.MOUSEBUTTONDOWN]
        self.highlight = self.get_highlight()
        self.normal_image = self.image
        self.signal = signal
        self.changed = False
node-message.py 文件源码 项目:wargame 作者: maximinus 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __init__(self, highlight, image, rect):
        super().__init__(rect, image)
        self.highlight = highlight
        self.normal_image = image
        self.messages.append(pygame.MOUSEMOTION)
        self.inside = False
        # create a new message type and save it
        self.message_id = MessageType.get_new()
mouse-over.py 文件源码 项目:wargame 作者: maximinus 项目源码 文件源码 阅读 44 收藏 0 点赞 0 评论 0
def __init__(self, highlight, image, rect):
        super().__init__(rect, image)
        self.highlight = highlight
        self.normal_image = image
        self.messages.append(pygame.MOUSEMOTION)
        self.inside = False
sprite.py 文件源码 项目:rpi_lcars 作者: tobykurien 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def handleEvent(self, event, clock):
        handled = False
        if not self.visible:
            self.focussed = False
            return handled

        if self.groups()[0].UI_PLACEMENT_MODE:
            if event.type == pygame.MOUSEBUTTONDOWN:
                self.pressed_time = pygame.time.get_ticks()
                self.focussed = True

            if event.type == pygame.MOUSEMOTION:
                if (self.focussed and pygame.time.get_ticks() - self.pressed_time > 1000):
                    self.long_pressed = True
                    self.rect.top = event.pos[1]
                    self.rect.left = event.pos[0]
                    self.dirty = 1            

            if event.type == pygame.MOUSEBUTTONUP:
                if self.handler:
                    self.handler(self, event, clock)
                    handled = True

                if self.focussed and self.long_pressed:
                    print event.pos[1], event.pos[0]

                self.pressed_time = 0
                self.long_pressed = False
                self.focussed = False

        return handled
logoimg.py 文件源码 项目:eduActiv8 作者: imiolek-ireneusz 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def handle(self, event):
        if event.type == pygame.MOUSEMOTION:
            # check if cursor is not in the top right corner as it would happen on mobile after finger up
            if event.pos[0] + event.pos[1] > 0:
                self.on_mouse_over()
            else:
                self.deselect_all()
                self.mainloop.info.buttons_restore()
                self.mainloop.info.reset_titles()

        elif event.type == pygame.MOUSEBUTTONUP and event.button == 1:
            if not (self.mainloop.m.ldrag or self.mainloop.m.rdrag):
                if self.mainloop.m.active_o is not None:
                    self.mainloop.m.active_o.state = 0
                    self.mainloop.m.active_o = None
                if self.mainloop.m.active_cat_o is not None:
                    self.mainloop.m.active_cat_o.deactivate()
                    self.mainloop.m.active_cat_o = None
                if self.state < 2:
                    self.mainloop.sfx.play(4)
                self.state = 2
                self.mainloop.m.active_cat = 0
                self.mainloop.m.game_constructor = game000.Board
                self.mainloop.m.game_variant = 0
                self.mainloop.m.active_game_id = 0
                self.mainloop.m.game_started_id = -1
                self.mainloop.m.tab_game_id = -5
                self.mainloop.m.tab_r_scroll = 0
                self.mainloop.redraw_needed = [True, True, True]
loginscreen.py 文件源码 项目:eduActiv8 作者: imiolek-ireneusz 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def handle(self, event):
        if self.visible:
            if event.type == pygame.MOUSEMOTION:
                self.onMouseMotion(event)
            elif event.type == pygame.MOUSEBUTTONDOWN:
                self.onMouseButtonDown()
            elif event.type == pygame.MOUSEBUTTONUP:
                self.onMouseButtonUp()
            elif event.type == pygame.KEYDOWN:
                self.onKeyDown(event)
loginscreen.py 文件源码 项目:eduActiv8 作者: imiolek-ireneusz 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def handle(self, event):
        if event.type == pygame.MOUSEMOTION:
            pos = event.pos
            for each in self.keys:
                if each.x < pos[0] < each.x + each.w and each.y < pos[1] < each.y + each.h:
                    each.mouse_over()
                    #each.handle(event)
                else:
                    each.mouse_out()

        elif event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
            if self.enabled:
                pos = event.pos
                for each in self.keys:
                    if each.x < pos[0] < each.x + each.w and each.y < pos[1] < each.y + each.h:
                        each.mouse_down()
                        each.handle(event)
                    else:
                        each.mouse_up()
        elif event.type == pygame.MOUSEBUTTONUP and event.button == 1:
            if self.enabled:
                pos = event.pos
                for each in self.keys:
                    each.mouse_up()
                    if each.x < pos[0] < each.x + each.w and each.y < pos[1] < each.y + each.h:
                        each.handle(event)
                        return
            self.update()
            self.ls.update_me = True
dialogwnd.py 文件源码 项目:eduActiv8 作者: imiolek-ireneusz 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def handle(self, event):
        if event.type == pygame.MOUSEMOTION or event.type == pygame.MOUSEBUTTONDOWN or event.type == pygame.MOUSEBUTTONUP:
            pos = [event.pos[0] - self.mainloop.game_board.layout.dialogwnd_pos[0],
                   event.pos[1] - self.mainloop.game_board.layout.dialogwnd_pos[1]]
            found = False
            for each in self.elements:
                if each.rect.topleft[0] + each.rect.width >= pos[0] >= each.rect.topleft[0] and each.rect.topleft[
                    1] + each.rect.height >= pos[1] >= each.rect.topleft[1]:
                    each.handle(event)
                    found = True
            if not found:
                for each in self.elements:
                    each.mouse_out()
        else:
            pass


问题


面经


文章

微信
公众号

扫码关注公众号