QConfirmDialog

thread: 6 messages  |  last: about 3 years ago  |  started: friday, july 11, 2008, 2:07 pm pdt


#1  |  VexedPanda (Calgary, AB) Canada
Friday, July 11, 2008, 2:07 PM PDT

I want a confirmation dialog with server-side generated messages. Has anyone built this yet?

Basically, I just want a QDialog with nameable buttons (at least two, but ideally a configurable number), and a way to register callbacks for when those buttons are hit.

If no one else has one, I'll be building one. How does the following syntax look?

<?
public function dlgConfirm_Create()
{
  $this->dlgConfirm = new QQuestionDialog($this);
  $this->dlgConfirm->Text = "Should I dissapear?";
  $this->dlgConfirm->AddButton('Yes', new QServerAction('btnYes_Click'));
  $this->dlgConfirm->AddButton('No', new QServerAction('btnNo_Click'));
  $this->dlgConfirm->AddButton('Maybe', new QServerAction('btnMaybe_Click'));
}

public function btnYes_Click()
{
  $this->dlgConfirm->HideDialog();
}
public function btnNo_Click()
{
  //don't do stuff
}
public function btnMaybe_Click()
{
  //Don't give up that easily
  $this->dlgConfirm->Text = "I mean it! Should I dissapear?";
  $this->dlgConfirm->RemoveButton('Maybe');
}
?>
.bc
#2  |  VexedPanda (Calgary, AB) Canada
Friday, July 11, 2008, 2:30 PM PDT

I'm starting to wonder if just using AutoRenderChildren would accomplish all that anyhow..

#3  |  VexedPanda (Calgary, AB) Canada
Friday, July 11, 2008, 5:00 PM PDT

Ok, here's what I came up with:

<?
protected function dlgConfirm_Create()
{
  $this->dlgConfirm = new QDialogBox($this);
  $this->dlgConfirm->Display = false;
  $this->dlgConfirm->AutoRenderChildren = true;

  $btnYes = new QButton($this->dlgConfirm);
  $btnYes->Text = "Yes";
  $btnYes->AddAction(new QClickEvent(), new QServerAction('btnYes_Click'));

  $btnNo = new QButton($this->dlgConfirm);
  $btnNo->Text = "No";
  //nothing happens

  $btnMaybe = new QButton($this->dlgConfirm, 'btnMaybe');
  $btnMaybe->Text = "Maybe";
  $btnMaybe->AddAction(new QClickEvent(), new QServerAction('btnMaybe_Click'));
}

public function btnYes_Click()
{
  $this->dlgConfirm->HideDialog();
}

public function btnMaybe_Click()
{
  //Don't give up that easily
  $this->dlgConfirm->Text = "I mean it! Should I dissapear?";
  $btnMaybe = $this->dlgConfirm->GetChildControl('btnMaybe');
  $btnMaybe->Visible = false;
}
?>

It's actually just as easy as I had envisioned my custom control being. :)

#4  |  Basilieus (Tucson,AZ) United States of America
Friday, July 25, 2008, 3:43 AM PDT

Hey panda.. just curious what is QForm::QConfirmAction ?

#5  |  VexedPanda (Calgary, AB) Canada
Monday, July 28, 2008, 10:08 AM PDT

It's QCodo's built-in javascript-based yes/no dialog. Basically, if the user clicks no, no other registered actions are triggered.

#6  |  alex94040 (Seattle, WA) United States of America Qcodo Core Contributor
Thursday, January 8, 2009, 2:37 PM PST

For anyone who's interested in this - we've developed several custom dialog boxes that will be included into QCubed; if you'd like to see them in action, they are here: <http://examples.qcu.be/examples/advanced_ajax/more_dialog_boxes.php>

QCubed is a community effort to take QCodo further. Join us! <http://qcu.be>



Copyright © 2005 - 2012, Quasidea Development, LLC
This open-source framework for PHP is released under the terms of The MIT License.