You need to have a variable (perhaps called buttonPressed) and when the physical button is pressed the variable is set to true
buttonPressed = true;
and in your stepper function and your solenoid function you will need code like
if (buttonPressed == true) {
// code to do stuff
}
You may get some ideas from Planning and Implementing a Program