Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
New Developer
lmuller
Posts: 20
Registered: ‎03-27-2012
My Device: Z10 LE, PlayBook & Dev Alpha C
Accepted Solution

How do you receive the text from a SystemPrompt in C++?

Hi!

 

I'm currently trying to use a SystemPrompt in my application but don't understand how to receive the text that the user has entered.

 

I'm using the example from:

http://developer.blackberry.com/cascades/documentation/ui/dialogs_toasts/prompts.html

 

The example shows:

void App::onPromptFinished(bb::system::SystemUiResult::Type type) {
    if (type != SystemUiResult::ConfirmButtonSelection)
        {
        qDebug() << "Prompt Accepted:" << text;
        // The user accepted the prompt.
        }
    else {
        qDebug() << "Prompt Rejected";
        // The user rejected the prompt.
    }
}

 Besides the bug in the example (the if statement should be == and not !=), I don't understand where text is suppose to be defined.

 

Any clues on how to get the value of text?

Developer
StevenKader
Posts: 648
Registered: ‎02-03-2010
My Device: Z10 LE

Re: How do you receive the text from a SystemPrompt in C++?

I think that sample won't work.  Need to have this line :

 

QString text = prompt->inputFieldTextEntry() ;

 

You can see in docs :  http://developer.blackberry.com/cascades/reference/bb__system__systemprompt.html#function-finished-v...


Steven Kader at JaredCo
   Follow me on Twitter    |     Mipixi.com :  Web App for Photo Sharing
New Developer
lmuller
Posts: 20
Registered: ‎03-27-2012
My Device: Z10 LE, PlayBook & Dev Alpha C

Re: How do you receive the text from a SystemPrompt in C++?

That's a bit annoying. So this means that prompt needs to be a member of my class and I need to keep creating and deleting this pointer everytime I use it? :\

Developer
Zmey
Posts: 1,523
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: How do you receive the text from a SystemPrompt in C++?

Not necessarily, you can retrieve the sender of a message in slot:

SystemPrompt *prompt = qobject_cast<SystemPrompt *>(sender());
QString text = prompt->inputFieldTextEntry() ;

I'm not sure if it will be deleted automatically, most likely it will not. So you could also destroy it in slot to prevent instances from accumulating:

prompt->deleteLater();

Andrey Fidrya, @zmeyc on twitter
New Developer
lmuller
Posts: 20
Registered: ‎03-27-2012
My Device: Z10 LE, PlayBook & Dev Alpha C

Re: How do you receive the text from a SystemPrompt in C++?

Contributor
danywarner
Posts: 38
Registered: ‎09-06-2013
My Device: BlackBerry Z10

Re: How do you receive the text from a SystemPrompt in C++?

Hey guys, I can't make it work. here is a bit of my code: 

 

void ApplicationUI::onPromptFinished(bb::system::SystemUiResult::Type type)
{

	SystemPrompt *prompt = qobject_cast<SystemPrompt *>(sender());
	QString text = prompt->inputFieldTextEntry() ;
    if (type != SystemUiResult::ConfirmButtonSelection)
    {

        qDebug() << "Prompt Accepted:"<<text ;
        // The user accepted the prompt.
    }
    else {
        qDebug() << "Prompt Rejected";
        // The user rejected the prompt.
    }
}

 is that right? 



_______________________________________________________
If you've been helped click on Like Button, if you've been saved download the app.

Developer of Easy Memes
Developer
Zmey
Posts: 1,523
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: How do you receive the text from a SystemPrompt in C++?

Hi! Looks correct. I'd also call prompt->deleteLater() at the end of function.

Does the function get called? If not, verify that QObject::connect() is returning true.

Andrey Fidrya, @zmeyc on twitter
Contributor
danywarner
Posts: 38
Registered: ‎09-06-2013
My Device: BlackBerry Z10

Re: How do you receive the text from a SystemPrompt in C++?

hey, thanks for your reply, it happened that the code in the example was wrong, whenever I tapped "OK" the function was taking the wrong way (Prompt rejected), the mistake was in the line 

 

if (type != SystemUiResult::ConfirmButtonSelection)

 I just changed it for 

if (type == SystemUiResult::ConfirmButtonSelection)

 



_______________________________________________________
If you've been helped click on Like Button, if you've been saved download the app.

Developer of Easy Memes