[Chameleon] button within a widget

Paul Spencer pagameba at magma.ca
Tue Oct 26 17:40:37 EDT 2004


You can easily do this ... the steps are (roughly):

* include the button code:

include_once( dirname(__FILE__)."/../Button.php" );

* add a class member variable to hold the button object:

class myWidget extends CWCWidget
{
var $moButton = null;


* In the constructor of your widget:

$this->moButton = new CWCButton( $this );

* In InitDefaults:

$this->moButton->InitDefaults();
$this->moButton->SetOnClick( 'myWidgetFunction' );

You will need to call all the functions that CWCButton uses, check 
Button.php to see which ones they are.  In general, it will be

function GetJavascriptIncludes()
{
     $aReturn = $this->moButton->GetJavascriptIncludes();

     //your includes

     return $aReturn;
}

there are several of these ... you need them ALL even if you don't do 
anything in the functions other than call the button function and return 
the resulting array.

in DrawPublish() you can now do:

$szButton = $this->moButton->DrawPublish();

and then incorporate $szButton into your output that gets returned from 
DrawPublish.

The button will call myWidgetFunction( ) when clicked.  myWidgetFunction 
will receive the button object as the first parameter, then any other 
parameters you supplied (see Button.php to pass other parameters, its 
not usually necessary)

Cheers,

Paul

Ken-ichi wrote:
> Hi all.  I'm developing a custom and rather non-standard widget that 
> shows geospatial datasets based on a rectangular query, and then allows 
> the user to choose which results to add to the map.  It's non-standard 
> because it shows results in the same window as the map, as opposed to a 
> popup.  I want to add a submit button to the widget's output 
> (DrawPublish()) but I'm not sure how to go about embedding a textbutton 
> within a widget.  I supposed I could just include the straight HTML for 
> the form input in my widget, but I'd like to just use a standard 
> Chameleon textbutton if possible.  Is there a way to do this?
> 
> Thanks.
> 
> -Ken-ichi
> _______________________________________________
> Chameleon mailing list
> Chameleon at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/chameleon
> 

-- 
  -----------------------------------------------------------------
|Paul Spencer                           pspencer at dmsolutions.ca   |
|-----------------------------------------------------------------|
|Applications & Software Development                              |
|DM Solutions Group Inc                 http://www.dmsolutions.ca/|
  -----------------------------------------------------------------



More information about the Chameleon mailing list