Hello,
I use:
NativeMessageBox::showOkCancelBox( MessageBoxIconType iconType,
const String& title,
const String& message,
Component* associatedComponent = nullptr,
ModalComponentManager::Callback* callback = nullptr );
but recently I found out it always return false
. Even though in documentation there is sentence:
If the callback parameter is not null, the method always returns false, and the user’s choice is delivered later by the callback.
So I started experimenting with:
ModalCallbackFunction::create( void(*)(int, ParamType) functionToCall,
ParamType parameterValue );
And the problem is it requires lambda which need to be static method. But I have in my class a lot of variables which are not static and I need to use them in the lambda. And as ParamType
need to be some primitive type so I can’t use the reference to my class.
So I found workout to use as ParamType
the void*
. And I cast my class instance to void*
and use it as a parameterValue
. And then inside of lambda method I use static_cast<myClass*>
and then I can use not static variables from instance of my class. And it works fine, but I didn’t any extensive tests.
So the questions are:
- Is it appropriate solution in my case?
- If it’s wrong solution, then what is best solution? Do I really need to remodel whole my class to have all necessary variables as a static variables?
For any advice great thanks in advance.
Best Regards