From ce4863ebc350f20a8d9858af700d091fd62dbce3 Mon Sep 17 00:00:00 2001
From: Victor Peyrade-Mathon <victor.peyrade-mathon@epitech.eu>
Date: Mon, 29 May 2023 14:44:04 +0200
Subject: [PATCH] [:bug: Fix outside limits selection]

---
 shukan/ShukanView.java | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/shukan/ShukanView.java b/shukan/ShukanView.java
index cdf4d7b..61d33bc 100644
--- a/shukan/ShukanView.java
+++ b/shukan/ShukanView.java
@@ -133,7 +133,7 @@ public class ShukanView extends JPanel
     return (appliHeight);
   }
 
-  /** Draws Shukan view. 
+  /** Draws Shukan view.
     */
   public void paintComponent (Graphics g)
   {
@@ -149,9 +149,9 @@ public class ShukanView extends JPanel
     for (i = 0; i <= nbModules; i++)
     {
       int y = appliHeight - (i + 1) * 3 * textHeight + 2*textHeight;
-    
-      
-      if (i % 2 == 1) 
+
+
+      if (i % 2 == 1)
       {
         g2.setColor (BACK_COLOR);
         drawBox (g2,0, y, w, 3 * textHeight);
@@ -162,19 +162,20 @@ public class ShukanView extends JPanel
         drawBox (g2, 0, y, w, 3 * textHeight);
       }
     }
-    
+
     displayCalendar (g2);
-  
+
   }
-  
 
- 
+
+
   /** Detects a zone from window coords.
    */
   public boolean select (int x, int y, boolean zone)
   {
     // Out of the active part of the window
     if (y < textHeight || y > appliHeight - 2 * textHeight) return (false);
+    if (x < 0 || x > appliWidth) return (false);
 
     // Module detection
     y -= textHeight;
@@ -235,7 +236,7 @@ public class ShukanView extends JPanel
       appliHeight = STD_APPLI_HEIGHT;
     }
   }
- 
+
   /** Displays the calendar grid background.
    */
   private void displayCalendar (Graphics2D g2)
-- 
GitLab