Page 1 of 1

C++ different calling code from click on ToggleButton vs check state from codebehind?

Posted: 16 Apr 2018, 20:46
by Wanderer
I have ToggleButton and this is in code
mf_function(true, this)
function looks like this (question in coments)
mf_function(const bool bTrue, myNoesisClass * t)
{
       if (t != nullptr)
       {
       // do something
       // when I click on the ToggleButton, this code is executed
       }
       else {
       // but when I call code mButton.SetIsChecked(true / false);
       // then this code is executed, it looks like when button is set checked from codebehind, "this" is not passed as argument, or it is nullptr ?
       }
}

Re: C++ different calling code from click on ToggleButton vs check state from codebehind?

Posted: 20 Apr 2018, 10:16
by sfernandez
I'm sorry but I don't understand well what you are trying to explain.

When you said that you have a ToggleButton and this code mf_function(true, this), what do you mean? That you call that function when the button is clicked?
From what I see you are responsible of calling mf_function, so you are the one passing the argument myNoesisClass * t to that function. Noesis doesn't know anything about it.

Re: C++ different calling code from click on ToggleButton vs check state from codebehind?

Posted: 20 Apr 2018, 11:36
by Wanderer
I apologize for not clear description.

When I click on button, mf_function() is executed because it is inside checkButton code. When I click on the button (from GUI), mf_function is called with this arguments mf_function(true, this) which is ok. ("this" means it pass whole class pointer from my custom userControl class in to arguments) But somewhere I have code where I switch this toggleButton codebehind, and from codebehind, when toggleButton is switched to notChecked, calling action not pass "this" (self pointer) in to arguments in mf_function() inside toggleButton code.
In fact, it is good for me now, because I need this behavior, but for future I am not sure if it is ok, this is reason I am asking for that.

Re: C++ different calling code from click on ToggleButton vs check state from codebehind?

Posted: 20 Apr 2018, 12:30
by Wanderer
Now I have problem, I have radioButtons and CheckButtons in my options menu, I load option data and from options I setIsCheck for all buttons. I am not sure if this is good idea. I have trigers and animations for disable and enable some areas to not do everything from codebehind. If I click on checkButton, area is enable/disabled, but when I call from codebehind SetIsChecked, then button is checked but trigger is not executed. Then desired area is not enabled when checkedButton is checked. My triggers are triggered to checked and unchecked buttons behavior.

Re: C++ different calling code from click on ToggleButton vs check state from codebehind?

Posted: 20 Apr 2018, 18:48
by Wanderer
Problem with calling IsChecked from codebehind is only when Grid is loaded and after that IsChecked is called. But when I call IsChecked from some button inside this new Grid, everything is working ok. If you don't unerstad I can create some video.

Re: C++ different calling code from click on ToggleButton vs check state from codebehind?

Posted: 24 Apr 2018, 12:00
by sfernandez
If you can create a ticket in our bugtracker with the code+xaml to reproduce the error it would be easier for us to debug what is failing and find a solution.
Could you please report it?

Re: C++ different calling code from click on ToggleButton vs check state from codebehind?

Posted: 28 Apr 2018, 15:54
by Wanderer
I apologize for late answer, yes I can, but for now I have not much time, soon as possible I create it.
For now I rewrite it everything in codebehind what is now more flexibile.

Btw, another problem for me is, when some object is deleted, like custom item (UserControl with buttons) from ListBox, all checked buttons are set to unchecked (before deleting) and then it call code. It is critical if it pass pointers from item, and then program crash, because function outside working with this pointer, but pointer have not data because is empty (deleted). And it lead to unwanted effect when code is calling without user interaction. I can avoid this problem with click event for each button.