@@ -77,7 +77,8 @@ def __init__(self, x, y, image, action):
77
77
self ._width = self .image .get_width ()
78
78
self ._height = self .image .get_height ()
79
79
80
- def is_in_bounds (self , x , y ):
80
+ def is_in_bounds (self , position ):
81
+ x , y = position
81
82
return (
82
83
self .x <= x <= self .x + self .width and self .y <= y <= self .y + self .height
83
84
)
@@ -184,6 +185,8 @@ def handle_events(self):
184
185
# If clicked in text area and book is still rendering, skip to the end
185
186
print (f"Left mouse button pressed at { event .pos } " )
186
187
# If button pressed while visible, trigger action
188
+ if self .back_button .is_in_bounds (event .pos ):
189
+ self .back_button .action ()
187
190
elif event .type == pygame .MOUSEBUTTONUP :
188
191
# Not sure if we will need this
189
192
print ("Mouse button has been released" )
@@ -345,7 +348,8 @@ def display_page_text(self):
345
348
self .add_page (paragraph_number , word_number )
346
349
return
347
350
348
- def create_transparent_buffer (self , size ):
351
+ @staticmethod
352
+ def create_transparent_buffer (size ):
349
353
if isinstance (size , (tuple , list )):
350
354
(width , height ) = size
351
355
elif isinstance (size , dict ):
@@ -374,7 +378,8 @@ def render_title(self):
374
378
375
379
return new_buffer
376
380
377
- def wrap_text (self , text , font , width ):
381
+ @staticmethod
382
+ def wrap_text (text , font , width ):
378
383
lines = []
379
384
line = ""
380
385
for word in text .split (" " ):
0 commit comments