Use keypress to stimulate fluid

Hi, I’ve been playing around with the ofxfluid but have been trying to stimulate fluid using the keypress but am unsure how to go about it.

So far I have tried this however it doesn’t disable the addition of fluid when the key is not pressed.

 #include "ofApp.h"

bool one = false;

ofPoint force;

//--------------------------------------------------------------
void testApp::setup(){
    ofEnableAlphaBlending();
    ofSetCircleResolution(100);
    
    width = 700;
    height = 600;

    // Initial Allocation
    fluid.allocate(width, height, .5);
    
    // Seting the gravity set up & injecting the background image
    force = ofPoint(0, 0);
    


    ofSetWindowShape(width, height);
}

//--------------------------------------------------------------
void testApp::update(){
    
    //  Update
    fluid.update();
    
}

//--------------------------------------------------------------
void testApp::draw(){
    ofBackgroundGradient(ofColor::gray, ofColor::black, OF_GRADIENT_LINEAR);
    
    fluid.draw();
    
    if (one)
    {
            fluid.addConstantForce(ofPoint(width*0.5,height*0.85), ofPoint(0,0),                            ofFloatColor(0.5,0.1,0.0), 10.f);
    }
    
}

//--------------------------------------------------------------
void testApp::keyPressed(int key){
    if( key == 'p')
        bPaint = !bPaint;
    if( key == 'o')
        bObstacle = !bObstacle;
    if( key == 'b')
        bBounding = !bBounding;
    if( key == 'c')
        bClear = !bClear;
    
    if(key =='1')
        one = true;
}

//--------------------------------------------------------------
void testApp::keyReleased(int key){
    if(key =='1') one = false;
}

does this behave any different?

change

if (one)

to

if ofGetKeyPressed('1')

and comment out the other “one” stuff

no, that behaves the same. Is note the keypress that’s the problem. It’s just that when I press the keypress, it stimulates the fluid however when pressed again it just adds to the fluid rather than resetting the demo.

I figured it out. I had to use temporal force in the fluid demo instead of constant force. Sorry! Was a silly mistake.