cancel
Showing results for 
Search instead for 
Did you mean: 

determine which button was pressed on a screen

FJB2069
Associate II

I have two buttons on Screen1.  Both interactions change screen to Screen2.  

Can I determine which button was pressed when in Screen2View::setup?

Or do I need to use a separate virtual functions and then create a variable setting the button called?

 

4 REPLIES 4
Marc_LM
Associate III

Go create a widget or a screen with many flex buttons.
In the base class you will see how the source of the button are detected.

void *::flexButtonCallbackHandler(const touchgfx::AbstractButtonContainer& src)

 

I see the flexButtonCallback in Screen1ViewBase.cpp.

I am trying to break on this section to follow when I press button, but only breaks when I return to screen, not button press.

Sorry, I am not familiar with how to use this callback or handler, any help would be appreciated!

 

wait, I see in the handler it shows each button.....  I will try to make a variable that saves which button was pressed so that after the data is input in screen2 I can return the data the correct flexbutton text area.

 

FJB2069
Associate II

How can I save which button was pressed in the Model before the screen is changed?

In the base view it shows which button was pressed, but how can I save that button into a variable using MVP ( I assume this would be the correct way) before the screen is changed.  then be able to access that variable when I return to screen 1?

void Screen1ViewBase::flexButtonCallbackHandler(const touchgfx::AbstractButtonContainer& src)
{
    if (&src== &flexButtonNum10s)
    {
        //Interaction1
        //When flexButtonNum10s clicked change screen to Screen2
        //Go to Screen2 with no screen transition
        application().gotoScreen2ScreenNoTransition();
    }
    if (&src== &flexButtonNum1s)
    {
        //Interaction2
        //When flexButtonNum1s clicked change screen to Screen2
        //Go to Screen2 with no screen transition
        application().gotoScreen2ScreenNoTransition();
    }
}