How to change LED Matrix text on button press while text is scrolling?

I'm working on an Arduino project where I'm making a clock that displays the time on a LED Matrix (Max72). I'm quite new to the Arduino and especially components such as the LED Matrix so I tried to find a Youtube tutorial. I found someone who made a similar project that displayed three different things on the Matrix: the time, the current day and the date. His version has the time displaying for around 50 seconds, then automatically moves to displaying the current day with a scrolling animation using the MD_Parola Library, and then displaying the date again with a scrolling animation. This just loops constantly. What I want is to be able to keep the time displayed until I press a button, then it moves on to the day with the scrolling animation, and it should keep scrolling until I press the button again and then display the date. When I press the button again, it should display the time again.

I tried to modify his code with my limited knowledge, but the problem is that when I press the button while the current day or date is scrolling, it doesn't actually read the button presses. It only recognizes the button presses in the split second where it's done scrolling and there is nothing on the screen. If I press the button while the text is scrolling, nothing happens. The button works perfectly when the time is displayed though, because the time is not scrolling, it's just printed.

This is my code so far:

#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
#include <DS3231.h>
#include <Wire.h>
DS3231 Clock;

bool Century=false;
bool h12;
bool PM;
byte  dd,mm,yyy;
uint16_t  h, m, s;
int val = 0;
int nmbrButtonPressed = 0;

#define buttonPin 6

#define MAX_DEVICES 4
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW 
#define CLK_PIN   13
#define DATA_PIN  11
#define CS_PIN    10
MD_Parola P = MD_Parola(HARDWARE_TYPE,CS_PIN, MAX_DEVICES);

#define SPEED_TIME 75 
#define PAUSE_TIME  0  

#define MAX_MESG  20

char szTime[9];    
char szMesg[MAX_MESG+1] = "";

uint8_t degC[] = { 6, 3, 3, 56, 68, 68, 68 }; 
uint8_t degF[] = { 6, 3, 3, 124, 20, 20, 4 }; 

char *mon2str(uint8_t mon, char *psz, uint8_t len)


{
  static const __FlashStringHelper* str[] =
  {
    F("Jan"), F("Feb"), F("Mar"), F("Apr"),
    F("May"), F("Jun"), F("Jul"), F("Aug"),
    F("Sep"), F("Oct"), F("Nov"), F("Dec")
  };

  strncpy_P(psz, (const char PROGMEM *)str[mon-1], len);
  psz[len] = '\0';

  return(psz);
}

char *dow2str(uint8_t code, char *psz, uint8_t len)
{
  static const __FlashStringHelper*  str[] =
  {
  F("Sunday"), F("Monday"), F("Tuesday"),
  F("Wednesday"), F("Thursday"), F("Friday"),
  F("Saturday"), F("Sunday")
  };

  strncpy_P(psz, (const char PROGMEM *)str[code-1], len);
  psz[len] = '\0';

  return(psz);
}
void getTime(char *psz, bool f = true)
{
  s = Clock.getSecond();
  m = Clock.getMinute();
    sprintf(psz, "%02d%c%02d", h, (f ? ':' : ' '), m);
    if (Clock.getHour(h12,PM)>=13 || Clock.getHour(h12,PM)==0)
  {
    h = Clock.getHour(h12,PM);
  }
  else
  { 
    h = Clock.getHour(h12,PM);
  }
 
}

void getDate(char *psz)
{
   char  szBuf[10];
 
  
   dd=Clock.getDate();
   mm=Clock.getMonth(Century); 
   yyy=Clock.getYear();
   sprintf(psz, "%d %s %04d",dd , mon2str(mm, szBuf, sizeof(szBuf)-1),(yyy + 2000));
}

void setup(void)
{
  P.begin(2);
  P.setInvert(false); 
  Wire.begin();
  
  P.setZone(0,  MAX_DEVICES-4, MAX_DEVICES-1);
  
  P.setZone(1, MAX_DEVICES-4, MAX_DEVICES-1);
  P.displayZoneText(1, szTime, PA_CENTER, SPEED_TIME, PAUSE_TIME, PA_PRINT, PA_NO_EFFECT);

  P.displayZoneText(0, szMesg, PA_CENTER, SPEED_TIME, 0,PA_PRINT , PA_NO_EFFECT);

  pinMode(buttonPin, INPUT_PULLUP);

  Serial.begin(57600);

}

void loop(void)
{
  static uint32_t lastTime = 0; 
  static uint8_t  display = 0;  
  static bool flasher = false;
  val = digitalRead(6);

  
  P.displayAnimate();

   if (P.getZoneStatus(0))
  {
    switch (display)
    {
      case 0: //current time

    if(nmbrButtonPressed == 0 && val == LOW){
      Serial.println("Button pressed, now displaying the day");  
      display = 1;
      P.setTextEffect(0, PA_PRINT, PA_SCROLL_UP);
      nmbrButtonPressed++;
      Serial.println(nmbrButtonPressed);
    }
     
     P.setTextEffect(0, PA_PRINT, PA_NO_EFFECT);
     P.setPause(0,0);

     if (millis() - lastTime >= 1000)
    {
    lastTime = millis();
    getTime(szMesg, flasher);
    flasher = !flasher;
    }
   
        break;
      
      case 1: // for example: Thursday

        if(nmbrButtonPressed == 1 && val == LOW){
          display = 2;
          Serial.println("Button pressed, now displaying date"); 
          nmbrButtonPressed++;
          Serial.println(nmbrButtonPressed);
        }
       
        P.setTextEffect(0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
        
        dow2str(Clock.getDoW()+1, szMesg, MAX_MESG); // Added +1 or +2 to get correct Day of Week

       
        break;

        
      case 2:  // for example: 20th of October 2021

        if (nmbrButtonPressed == 2 && val == LOW)
        {
          display = 0;
          Serial.println("Button pressed,now displaying time!");
          nmbrButtonPressed = 0;
          Serial.println(nmbrButtonPressed); 
        }
        
        P.setTextEffect(0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
        getDate(szMesg);


        break;

        default:
        break;
    }

    P.displayReset(0);  
  }

} 

I haven't worked with the Parola-library

as the Parola-library has only a call to

P.displayAnimate();

The animation seems to be done completely inside the library

I used the LEDMatrixDriver
where the animation is done outside the library
I used the example
marqueetext
there the text shown on the display is stored in an array of char

char text[] = "** LED MATRIX DEMO! ** (1234567890) ++ \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\" ++ <$%/=?'.@,> --";

and the content of this can be changed easily on runtime.
anyway there is no way around learning more about the library and how the text is stored for both libraries

best regards Stefan