Python pygame.MOUSEBUTTONUP Examples
The following are 30
code examples of pygame.MOUSEBUTTONUP().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pygame
, or try the search function
.

Example #1
Source File: rigeditor.py From renpy-shader with MIT License | 8 votes |
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)
Example #2
Source File: game004.py From eduActiv8 with GNU General Public License v3.0 | 7 votes |
def handle(self, event): gd.BoardGame.handle(self, event) if event.type == pygame.MOUSEMOTION or event.type == pygame.MOUSEBUTTONUP: pos = [event.pos[0] - self.layout.game_left, event.pos[1] - self.layout.top_margin] found = False for each in self.units: if (each.rect.left < pos[0] < each.rect.right and each.rect.top < pos[1] < each.rect.bottom): if each != self.unit_mouse_over: if self.unit_mouse_over is not None: self.unit_mouse_over.mouse_out() self.unit_mouse_over = each found = True each.handle(event) break if not found: if self.unit_mouse_over is not None: self.unit_mouse_over.mouse_out() self.unit_mouse_over = None self.board.mainloop.redraw_needed[0] = True
Example #3
Source File: Input.py From three.py with MIT License | 7 votes |
def update(self): self.keyDownList = [] self.keyUpList = [] self.mouseButtonDown = False self.mouseButtonUp = False self.windowResize = False for event in pygame.event.get(): # checks input events (discrete) if event.type == pygame.KEYDOWN: self.keyDownList.append( event.key ) self.keyPressedList.append( event.key ) elif event.type == pygame.KEYUP: self.keyPressedList.remove( event.key ) self.keyUpList.append( event.key ) elif event.type == pygame.MOUSEBUTTONDOWN: self.mouseButtonDown = True self.mouseButtonPressed = True elif event.type == pygame.MOUSEBUTTONUP: self.mouseButtonPressed = False self.mouseButtonUp = True elif event.type == pygame.QUIT: self.quitStatus = True elif event.type == pygame.VIDEORESIZE: self.windowResize = True self.windowWidth = event.w self.windowHeight = event.h
Example #4
Source File: game038.py From eduActiv8 with GNU General Public License v3.0 | 6 votes |
def handle(self, event): gd.BoardGame.handle(self, event) if event.type == pygame.MOUSEBUTTONDOWN: self.active_item = self.board.ships[self.board.active_ship] if self.active_item.unit_id < 20: self.current_letter_index = self.active_item.unit_id self.activate_letter() else: pos = [event.pos[0] - self.layout.game_left, event.pos[1] - self.layout.top_margin] if self.lt.rect.topleft[0] < pos[0] < self.lt.rect.topleft[0] + self.lt.rect.width and \ self.lt.rect.topleft[1] < pos[1] < self.lt.rect.topleft[ 1] + self.lt.rect.height: self.next_slide(-1) elif self.rt.rect.topleft[0] < pos[0] < self.rt.rect.topleft[0] + self.rt.rect.width and \ self.rt.rect.topleft[1] < pos[1] < self.rt.rect.topleft[ 1] + self.rt.rect.height: self.next_slide(1) if event.type == pygame.MOUSEMOTION or event.type == pygame.MOUSEBUTTONUP: self.default_hover(event)
Example #5
Source File: sprite.py From pi-tracking-telescope with MIT License | 6 votes |
def handleEvent(self, event, clock): if not self.visible: self.focussed = False return 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.focussed and self.long_pressed: print event.pos[1], event.pos[0] self.pressed_time = 0 self.long_pressed = False self.focussed = False
Example #6
Source File: gui.py From openag_brain_box with GNU General Public License v3.0 | 5 votes |
def handleEvents(self): for event in pygame.event.get(): if event.type == pygame.QUIT or (event.type == KEYDOWN and event.key == K_ESCAPE) : self.webcam.stop() pygame.quit() sys.exit() elif event.type == pygame.MOUSEBUTTONUP: x,y = pygame.mouse.get_pos() logger.info('{}, {}'.format(x,y)) if 320<x<800: if self.canny: self.canny = False else: self.canny = True
Example #7
Source File: rc_play.py From reconchess with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self): self.window = Window() self.window.register_callback(pygame.MOUSEBUTTONUP, self._handle_mouse_up) self.board = None self.color = None self.ally_capture_square = None self.enemy_capture_square = None
Example #8
Source File: viewfinder.py From viewfinder with Apache License 2.0 | 5 votes |
def ProcessMotion(vf_time): """Process pygame events for the window. Mousedown in the target area starts the simulation. Mouse movement is reported to the 'vf_time' arg to adjust the current time. Mouseup stop the simulation. """ last_pos = None for event in pygame.event.get(): if event.type == pygame.QUIT or event.type == pygame.KEYDOWN: return sys.exit(0) if vf_time.IsActive(): if event.type == pygame.MOUSEMOTION: if event.buttons[0]: last_pos = event.pos elif event.type == pygame.MOUSEBUTTONUP: if event.button == 1: vf_time.Stop() else: if event.type == pygame.MOUSEBUTTONDOWN: if event.button == 1: pos = PixelsToDimensions(event.pos) x, y = pos if x > iphone_dims[0] - target_box_width - target_box_padding and \ x < iphone_dims[0] - target_box_padding and \ y > target_box_padding and \ y < iphone_dims[1] - target_box_padding: vf_time.Start(pos) if last_pos: vf_time.AdjustTime(PixelsToDimensions(last_pos))
Example #9
Source File: timeline.py From viewfinder with Apache License 2.0 | 5 votes |
def ProcessMotion(active, last_pos): new_pos = last_pos for event in pygame.event.get(): if event.type == pygame.QUIT or event.type == pygame.KEYDOWN: return sys.exit(0) if active: if event.type == pygame.MOUSEMOTION: if event.buttons[0]: new_pos = event.pos elif event.type == pygame.MOUSEBUTTONUP: if event.button == 1: active = False else: if event.type == pygame.MOUSEBUTTONDOWN: if event.button == 1: x_pos, y_pos = [float(pos) / dim for pos, dim in zip(event.pos, window_dimensions)] if x_pos > (1.0 - target_box_width - target_box_padding) and \ x_pos < (1.0 - target_box_padding) and \ y_pos > target_box_padding and \ y_pos < 1.0 - target_box_padding: active = True new_pos = event.pos x_ratio = EnforceBounds(float(new_pos[0]) / window_dimensions[0], 0.0, 1.0) old_y_ratio = EnforceBounds(float(last_pos[1]) / window_dimensions[1], 0.0, 1.0) y_ratio = EnforceBounds(float(new_pos[1]) / window_dimensions[1], 0.0, 1.0) y_delta = y_ratio - old_y_ratio return active, new_pos, x_ratio, y_ratio, y_delta
Example #10
Source File: viewfinder.py From viewfinder with Apache License 2.0 | 5 votes |
def ProcessMotion(vf_time): """Process pygame events for the window. Mousedown in the target area starts the simulation. Mouse movement is reported to the 'vf_time' arg to adjust the current time. Mouseup stop the simulation. """ last_pos = None for event in pygame.event.get(): if event.type == pygame.QUIT or event.type == pygame.KEYDOWN: return sys.exit(0) if vf_time.IsActive(): if event.type == pygame.MOUSEMOTION: if event.buttons[0]: last_pos = event.pos elif event.type == pygame.MOUSEBUTTONUP: if event.button == 1: vf_time.Stop() else: if event.type == pygame.MOUSEBUTTONDOWN: if event.button == 1: pos = PixelsToDimensions(event.pos) x, y = pos if x > iphone_dims[0] - target_box_width - target_box_padding and \ x < iphone_dims[0] - target_box_padding and \ y > target_box_padding and \ y < iphone_dims[1] - target_box_padding: vf_time.Start(pos) if last_pos: vf_time.AdjustTime(PixelsToDimensions(last_pos))
Example #11
Source File: timeline.py From viewfinder with Apache License 2.0 | 5 votes |
def ProcessMotion(active, last_pos): new_pos = last_pos for event in pygame.event.get(): if event.type == pygame.QUIT or event.type == pygame.KEYDOWN: return sys.exit(0) if active: if event.type == pygame.MOUSEMOTION: if event.buttons[0]: new_pos = event.pos elif event.type == pygame.MOUSEBUTTONUP: if event.button == 1: active = False else: if event.type == pygame.MOUSEBUTTONDOWN: if event.button == 1: x_pos, y_pos = [float(pos) / dim for pos, dim in zip(event.pos, window_dimensions)] if x_pos > (1.0 - target_box_width - target_box_padding) and \ x_pos < (1.0 - target_box_padding) and \ y_pos > target_box_padding and \ y_pos < 1.0 - target_box_padding: active = True new_pos = event.pos x_ratio = EnforceBounds(float(new_pos[0]) / window_dimensions[0], 0.0, 1.0) old_y_ratio = EnforceBounds(float(last_pos[1]) / window_dimensions[1], 0.0, 1.0) y_ratio = EnforceBounds(float(new_pos[1]) / window_dimensions[1], 0.0, 1.0) y_delta = y_ratio - old_y_ratio return active, new_pos, x_ratio, y_ratio, y_delta
Example #12
Source File: pyos.py From PythonOS with MIT License | 5 votes |
def check(self): for event in pygame.event.get(): if event.type == pygame.QUIT: State.exit() if event.type == pygame.MOUSEBUTTONDOWN: self.events.append(GUI.LongClickEvent(event)) if event.type == pygame.MOUSEMOTION and len(self.events) > 0 and isinstance(self.events[len(self.events)-1], GUI.LongClickEvent): self.events[len(self.events)-1].intermediateUpdate(event) if event.type == pygame.MOUSEBUTTONUP and len(self.events) > 0 and isinstance(self.events[len(self.events)-1], GUI.LongClickEvent): self.events[len(self.events)-1].end(event) if not self.events[len(self.events)-1].checkValidLongClick(): self.events[len(self.events)-1] = self.events[len(self.events)-1].mouseUp
Example #13
Source File: gui.py From ct-Raspi-Radiowecker with GNU General Public License v3.0 | 5 votes |
def process_events(self): clicked = False events = pygame.event.get() for event in events: # if the event is any type of quit request end the program if event.type == pygame.QUIT: quit() # resize the window if its requested elif event.type == pygame.VIDEORESIZE: self.window_size = event.size self.display_resize() # evaluate keypresses elif event.type == pygame.KEYDOWN: # exit on Escape if event.key == pygame.K_ESCAPE: quit() # switch to fullscreen on F11 elif event.key == pygame.K_F11: self.fullscreen = not self.fullscreen # evaluate all presses of the left mousebutton elif event.type == pygame.MOUSEBUTTONUP and event.button == 1: clicked = True self.clicktime = pygame.time.get_ticks() self.clickEvent = event click = None timediff = pygame.time.get_ticks() - self.clicktime if clicked and self.await_dblclk == False and self.click is None: self.await_dblclk = True pass elif clicked and timediff < self.dblclktime and self.await_dblclk: click = "double" self.await_dblclk = False elif timediff > self.dblclktime and self.await_dblclk: click = "single" self.await_dblclk = False if click != None: self.await_dblclk = False self.clicktime = 0 for element in self.elements: if hasattr(element, 'Callback') and element.Callback != None and element.Rect.collidepoint(self.clickEvent.pos): if click == "double" and element.DblclkCallback != None: element.DblclkCallback() else: element.Callback() # exit the programm
Example #14
Source File: MessageDialog.py From PhotonFileEditor with GNU General Public License v3.0 | 5 votes |
def waitforuser(self): """ Blocks all events to Main window and wait for user to click OK. """ while self.waiting: self.redraw() pygame.display.flip() for event in pygame.event.get(): pos = pygame.mouse.get_pos() gpos=GPoint().fromTuple(pos) if event.type == pygame.MOUSEBUTTONUP: if self.dragDiff==None: for ctrl in self.controls: ctrl.handleMouseUp(pos,event.button) else: # handle window move self.dragDiff=None if event.type == pygame.MOUSEBUTTONDOWN: if gpos.inGRect(self.titlerect): self.dragDiff = gpos - self.winrect.p1 else: for ctrl in self.controls: ctrl.handleMouseDown(pos,event.button) if event.type == pygame.MOUSEMOTION: if not self.dragDiff==None: self.winrect.p1=gpos-self.dragDiff self.reposControls() else: for ctrl in self.controls: ctrl.handleMouseMove(pos) if event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: print("Escape key pressed down.") self.waiting = False
Example #15
Source File: FileDialog.py From PhotonFileEditor with GNU General Public License v3.0 | 5 votes |
def waitforuser(self): """ Blocks all events to Main window and wait for user to click OK. """ while self.waiting: self.redraw() pygame.display.flip() for event in pygame.event.get(): pos = pygame.mouse.get_pos() gpos=GPoint().fromTuple(pos) if event.type == pygame.MOUSEBUTTONUP: if self.dragDiff==None: for ctrl in self.controls: ctrl.handleMouseUp(pos,event.button) else: # handle window move self.dragDiff=None if event.type == pygame.MOUSEBUTTONDOWN: if gpos.inGRect(self.titlerect): self.dragDiff = gpos - self.winrect.p1 else: for ctrl in self.controls: ctrl.handleMouseDown(pos,event.button) if event.type == pygame.MOUSEMOTION: if not self.dragDiff==None: self.winrect.p1=gpos-self.dragDiff self.reposControls() else: for ctrl in self.controls: ctrl.handleMouseMove(pos) if event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: print("Escape key pressed down.") self.waiting = False else: self.tbFilename.handleKeyDown(event.key, event.unicode)
Example #16
Source File: game078.py From eduActiv8 with GNU General Public License v3.0 | 5 votes |
def handle(self, event): gd.BoardGame.handle(self, event) if event.type == pygame.MOUSEBUTTONDOWN and self.history[1] is None and self.ai_enabled is False: if 0 <= self.board.active_ship < self.square_count: active = self.board.ships[self.board.active_ship] if not active.uncovered: if self.history[0] is None: self.history[0] = active self.semi_select(active) self.clicks += 1 active.uncovered = True elif self.history[1] is None: self.history[1] = active self.semi_select(active) self.clicks += 1 if self.chosen[self.history[0].unit_id] != self.chosen[self.history[1].unit_id]: self.ai_enabled = True self.history[0].uncovered = False else: self.select() self.found += 2 if self.found == self.square_count: self.completed_mode = True self.ai_enabled = True active.update_me = True if event.type == pygame.MOUSEMOTION or event.type == pygame.MOUSEBUTTONUP: self.custom_hover(event)
Example #17
Source File: game076.py From eduActiv8 with GNU General Public License v3.0 | 5 votes |
def handle(self, event): gd.BoardGame.handle(self, event) # send event handling up if not self.show_msg: if event.type == pygame.KEYDOWN and (event.key == pygame.K_RIGHT or event.key == pygame.K_LEFT): self.next_step() elif event.type == pygame.MOUSEBUTTONUP: if self.board.active_ship == self.next_step_btn.unit_id: if self.current_pos + 1 > self.all_a_count: self.level.next_board_load() else: self.next_step()
Example #18
Source File: game039.py From eduActiv8 with GNU General Public License v3.0 | 5 votes |
def handle(self, event): gd.BoardGame.handle(self, event) if 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) self.auto_check() if event.type == pygame.MOUSEMOTION or event.type == pygame.MOUSEBUTTONUP: self.default_hover(event)
Example #19
Source File: game060.py From eduActiv8 with GNU General Public License v3.0 | 5 votes |
def handle(self, event): gd.BoardGame.handle(self, event) if event.type == pygame.MOUSEBUTTONDOWN and self.history[1] is None and self.ai_enabled is False: if 0 <= self.board.active_ship < self.square_count: active = self.board.ships[self.board.active_ship] if not active.uncovered: if self.history[0] is None: self.history[0] = active self.semi_select(active) self.clicks += 1 active.uncovered = True elif self.history[1] is None: self.history[1] = active self.semi_select(active) self.clicks += 1 if self.chosen[self.history[0].unit_id] != self.chosen[self.history[1].unit_id]: self.ai_enabled = True self.history[0].uncovered = False else: self.select() self.found += 2 if self.found == self.square_count: self.completed_mode = True self.ai_enabled = True active.update_me = True if event.type == pygame.MOUSEMOTION or event.type == pygame.MOUSEBUTTONUP: self.custom_hover(event)
Example #20
Source File: game075.py From eduActiv8 with GNU General Public License v3.0 | 5 votes |
def handle(self, event): gd.BoardGame.handle(self, event) # send event handling up if not self.show_msg: if event.type == pygame.KEYDOWN and (event.key == pygame.K_RIGHT or event.key == pygame.K_LEFT): self.next_step() elif event.type == pygame.MOUSEBUTTONUP: if self.board.active_ship == self.next_step_btn.unit_id: if self.current_pos + 1 > self.all_a_count: self.level.next_board_load() else: self.next_step()
Example #21
Source File: game049.py From eduActiv8 with GNU General Public License v3.0 | 5 votes |
def handle(self, event): gd.BoardGame.handle(self, event) if 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) if self.data[5] == 1: self.auto_check() self.check_result() if event.type == pygame.MOUSEMOTION or event.type == pygame.MOUSEBUTTONUP: self.default_hover(event)
Example #22
Source File: game041.py From eduActiv8 with GNU General Public License v3.0 | 5 votes |
def handle(self, event): gd.BoardGame.handle(self, event) # send event handling up if event.type == pygame.KEYDOWN or event.type == pygame.MOUSEBUTTONDOWN: self.auto_check_reset() elif event.type == pygame.MOUSEBUTTONUP and event.button == 1: self.draw_lines() self.mainloop.redraw_needed[0] = True self.check_result() if event.type == pygame.MOUSEMOTION or event.type == pygame.MOUSEBUTTONUP: self.default_hover(event)
Example #23
Source File: game019.py From eduActiv8 with GNU General Public License v3.0 | 5 votes |
def handle(self, event): gd.BoardGame.handle(self, event) if 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) self.auto_check() if event.type == pygame.MOUSEMOTION or event.type == pygame.MOUSEBUTTONUP: self.default_hover(event)
Example #24
Source File: game073.py From eduActiv8 with GNU General Public License v3.0 | 5 votes |
def handle(self, event): gd.BoardGame.handle(self, event) # send event handling up if not self.show_msg: if event.type == pygame.KEYDOWN and (event.key == pygame.K_RIGHT or event.key == pygame.K_LEFT): self.next_step() elif event.type == pygame.MOUSEBUTTONUP: if self.board.active_ship == self.next_step_btn.unit_id: if self.cursor_pos == self.sumn1n2sl + 1: self.level.next_board_load() else: self.next_step()
Example #25
Source File: game045.py From eduActiv8 with GNU General Public License v3.0 | 5 votes |
def handle(self, event): gd.BoardGame.handle(self, event) # send event handling up if event.type == pygame.KEYDOWN or event.type == pygame.MOUSEBUTTONDOWN: self.auto_check_reset() if event.type == pygame.MOUSEMOTION or event.type == pygame.MOUSEBUTTONUP: self.default_hover(event)
Example #26
Source File: game112.py From eduActiv8 with GNU General Public License v3.0 | 5 votes |
def handle(self, event): gd.BoardGame.handle(self, event) if 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) self.check_result() if event.type == pygame.MOUSEMOTION or event.type == pygame.MOUSEBUTTONUP: self.default_hover(event)
Example #27
Source File: game044.py From eduActiv8 with GNU General Public License v3.0 | 5 votes |
def handle(self, event): gd.BoardGame.handle(self, event) # send event handling up if event.type == pygame.MOUSEBUTTONUP: self.check_result()
Example #28
Source File: game042.py From eduActiv8 with GNU General Public License v3.0 | 5 votes |
def handle(self, event): gd.BoardGame.handle(self, event) # send event handling up if event.type == pygame.KEYDOWN or event.type == pygame.MOUSEBUTTONDOWN: self.auto_check_reset() if event.type == pygame.MOUSEMOTION: if self.drag: self.swap_font_color() # if self.drag and self.mouse_entered_new: # self.swap_font_color() elif event.type == pygame.MOUSEBUTTONUP: self.swap_font_color() self.check_result() # if self.drag and self.mouse_entered_new: # self.swap_font_color()
Example #29
Source File: game032.py From eduActiv8 with GNU General Public License v3.0 | 5 votes |
def handle(self, event): gd.BoardGame.handle(self, event) # send event handling up if event.type == pygame.MOUSEBUTTONDOWN: self.auto_check_reset() if event.type == pygame.MOUSEMOTION or event.type == pygame.MOUSEBUTTONUP: self.default_hover(event)
Example #30
Source File: game074.py From eduActiv8 with GNU General Public License v3.0 | 5 votes |
def handle(self, event): gd.BoardGame.handle(self, event) # send event handling up if not self.show_msg: if event.type == pygame.KEYDOWN and (event.key == pygame.K_RIGHT or event.key == pygame.K_LEFT): self.next_step() elif event.type == pygame.MOUSEBUTTONUP: if self.board.active_ship == self.next_step_btn.unit_id: if self.cursor_pos == self.sumn1n2sl + 1: self.level.next_board_load() else: self.next_step()