Skip to content

Commit

Permalink
Merge pull request #1 from kerodekroma/fix/mouse-event
Browse files Browse the repository at this point in the history
fix | adding improvement in usability
  • Loading branch information
kerodekroma authored May 12, 2024
2 parents 0c276fb + 20f195e commit 56f973a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions py_singl_slider.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ def listen_event(self, event):
if event.type == pygame.MOUSEBUTTONUP or event.type == pygame.FINGERUP:
self.is_handler_down = False

if self.is_handler_down:
pos_x = mouse_pos[0]
self.handler_rect.x = min((self.bar_width + self.bar_x), max(pos_x, self.bar_x))
self.value = self.get_current_value()

if (event.type == pygame.MOUSEMOTION or event.type == pygame.FINGERMOTION) and self.is_handler_down:
pos_x = (mouse_pos[0] - self.bar_x)
self.handler_rect.x = min((self.bar_width + self.bar_x), max(pos_x, self.bar_x))
Expand Down

0 comments on commit 56f973a

Please sign in to comment.