Levis
April 7, 2015, 10:49am
#1
Is there any builtin native method for showing Messagebox crossplatform?
I’ve seen this:
bool ShowMessageBox (Platform::String^ title,Platform::String^ message)
Don’t know it is something like this:
http://developer.xamarin.com/guides/cross-platform/xamarin-forms/working-with/pop-ups/Images/alert1.png
Is it possible or I have to build this class myself?
Thank you for help
You can use MessageBox("my message", "title");
2 Likes
Levis
April 8, 2015, 8:15am
#3
Thank you very much.
I didn’t found this neither in wiki, api and guide
Levis
April 8, 2015, 1:38pm
#4
Just for completeness, is there something builtin also for confirm dialog? (yes/no)
Thank you.
These type of messages or alerts are called roster messages
i think.
these things are there in respective OS SDK’s i believe…
but @stevetranby is MessageBox() present in the cocos api… !!
and could you sight a simple example of how to use it… !!
That would help…
There is no prompt
in the engine. You can see the code in the ./cocos/platform/CCCommon.h
and associated implementations are in each folder: CCCommon-ios.mm, CCCommon-mac.mm, CCCommon-android.java. Looks like linux is not supported yet. You could probably duplicate it into a prompt (two button) version, except that the callback will be more work and a little tricky. I’ve done this prompt for testing iAP in iOS/Mac/Android, but it’s not in a nice format like plugin-x will hopefully do in the future.
// declaration
void CC_DLL MessageBox(const char * msg, const char * title);
// usage (it's in global namespace)
MessageBox("Congrats on completing the game!", "Victory");
1 Like
thanks @stevetranby
I though this thing can only be done by calling from the wrapper class to the SDK.
but thankfully, cocos2d-x has something already.
Strange that it is not in the api…
may be i can ask jason to look into it… or may be it is not added intentionally or something…
anyway thanks again…
Maybe someone would want to extend the source I provided to include Windows/Phone/Linux/Mac? And once that is done it can get rolled in to Cocos core.
Attached are the files for I build for doing native alerts for Cocos 3.x for iOS and Android. There are two functions that can be used, one with callback and up to 3 buttons, and one without callback and only 1 button (simplified as a replacement for MessageBox).
To use the simplified version just call:
cocos2d::NativeAlert::show( "Alert Title", "This is the message that shows in the alert.", "Close button" );
To use the callback version, your class must implement a callback function:
void …
2 Likes
Levis
April 9, 2015, 8:08am
#9
It will be very good if it will be inserted in Cocos core!
umai
May 26, 2015, 3:31am
#10
I agree. This should definitely be in a cross platform suite.