×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    6

    CAknTextQueryDialog

    Is it possible to use CAknTextQueryDialog to enter empty strings? The dialog as shown in examples disables "Ok" button if user hasn't entered any characters or clears the text. I need a query dlg that also allows empty strings to be entered.

  2. #2
    Registered User
    Join Date
    Mar 2003
    Posts
    6
    Ok, here's how you do it.

    1. Derive from CAknQueryDialog
    2. Override HandleQueryEditorStateEventL and call MakeLeftSoftkeyVisible(ETrue); each time the event is received
    3. Use CAknQueryControl to access the string
    [4. You may also want to override OkToExitL or some such method where you get the value from the CAknQueryControl and store it somewhere for later use]

    ----cut here-------
    CPP:
    class CMyQuery : public CAknQueryDialog
    {
    public:
    CMyQuery(TDesC &prompt) : CAknQueryDialog(prompt){}
    ~CMyQuery() {}

    TBool RunMeL(TDesC aValue, TInt aResId){
    CAknQueryControl *ew;
    PrepareLC(aResId);
    //assumes that query control has id EGeneralQuery
    ew = (CAknQueryControl *)Control(EGeneralQuery);
    ew->SetTextL(aValue);
    MakeLeftSoftkeyVisible(ETrue);
    if(!RunLD())
    return EFalse;

    return ETrue;
    }

    virtual TBool HandleQueryEditorStateEventL(CAknQueryControl *aQueryControl, TQueryControlEvent aEventType, TQueryValidationStatus aStatus){
    TBool b = CAknQueryDialog::HandleQueryEditorStateEventL(aQueryControl, aEventType, aStatus);
    MakeLeftSoftkeyVisible(ETrue);
    return b;
    }
    };

    RSS:
    RESOURCE DIALOG r_string_setting
    {
    flags = EGeneralQueryFlags;
    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
    items=
    {
    DLG_LINE
    {
    type = EAknCtQuery;
    id = EGeneralQuery;
    control= AVKON_DATA_QUERY
    {
    layout = EDataLayout;
    label = LABEL_NAME_OF_FAV_LOCATION;
    control = EDWIN
    {
    flags= EEikEdwinNoHorizScrolling | EEikEdwinResizable;
    maxlength = 100;
    width = 5;
    lines = 1;
    };
    };
    }
    };
    }

  3. #3
    Registered User
    Join Date
    May 2008
    Posts
    5

    Re: CAknTextQueryDialog

    nikohaatainen, it is too complicated!

    Certainly, you should derive from CAknTextQueryDialog.
    But you need not override HandleQueryEditorStateEventL. Just override UpdateLeftSoftKeyL() from CAknQueryDialog.

    Seems that this code is enough:

    Code:
    class CTextQueryAllowEmpty : public CAknTextQueryDialog {
    public:
    	CTextQueryAllowEmpty( TDes& text ) : CAknTextQueryDialog( text ) {}
    	
    	// seems like developers from Series60 wanted this function to do this:
    	virtual void UpdateLeftSoftKeyL() {
    		]MakeLeftSoftkeyVisible( CheckIfEntryTextOk() );
    	}
    	// allow any string
    	virtual TBool CheckIfEntryTextOk() const { return true; }
    };
    
    const int MaxEditWordLength = 127;
    
    void FooBarL()
    {
    	TBuf<MaxEditWordLength + 1> textToEdit( originalText );
    
    	CTextQueryAllowEmpty* myDialog = new( ELeave ) CTextQueryAllowEmpty( textToEdit );
    	// your resource r_string_setting
    	myDialog->PrepareLC( R_STRING_SETTING );
    	myDialog->SetMaxLength( MaxEditWordLength );
    
    	if( myDialog->RunLD() ) {
    		// make something with 'textToEdit'
    	}
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×