class SampleUIButtons extends inkLogicController
{
	private editable var m_Button : inkWidgetRef;
	private editable var m_Toggle1 : inkWidgetRef;
	private editable var m_Toggle2 : inkWidgetRef;
	private editable var m_Toggle3 : inkWidgetRef;
	private editable var m_RadioGroup : inkWidgetRef;
	private editable var m_Text : inkTextRef;

	protected event OnInitialize()
	{
		var button : weak< inkButtonController >;
		var toggle : weak< inkToggleController >;
		var radio : weak< inkRadioGroupController >;
		button = ( ( inkButtonController )( inkWidgetRef.GetControllerByType( m_Button, 'inkButtonController' ) ) );
		if( button )
		{
			button.RegisterToCallback( 'OnButtonClick', this, 'OnButtonClick' );
			button.RegisterToCallback( 'OnButtonHoldComplete', this, 'OnButtonHoldComplete' );
		}
		toggle = ( ( inkToggleController )( inkWidgetRef.GetControllerByType( m_Toggle1, 'inkToggleController' ) ) );
		if( toggle )
		{
			toggle.RegisterToCallback( 'OnButtonClick', this, 'OnToggle1Click' );
			toggle.RegisterToCallback( 'OnToggleChanged', this, 'OnToggle1Changed' );
		}
		toggle = ( ( inkToggleController )( inkWidgetRef.GetControllerByType( m_Toggle2, 'inkToggleController' ) ) );
		if( toggle )
		{
			toggle.RegisterToCallback( 'OnButtonClick', this, 'OnToggle2Click' );
			toggle.RegisterToCallback( 'OnToggleChanged', this, 'OnToggle2Changed' );
		}
		toggle = ( ( inkToggleController )( inkWidgetRef.GetControllerByType( m_Toggle3, 'inkToggleController' ) ) );
		if( toggle )
		{
			toggle.RegisterToCallback( 'OnButtonClick', this, 'OnToggle3Click' );
			toggle.RegisterToCallback( 'OnToggleChanged', this, 'OnToggle3Changed' );
		}
		radio = ( ( inkRadioGroupController )( inkWidgetRef.GetControllerByType( m_RadioGroup, 'inkRadioGroupController' ) ) );
		if( radio )
		{
			radio.RegisterToCallback( 'OnValueChanged', this, 'OnRadioValueChanged' );
		}
	}

	private function SetText( const text : ref< String > )
	{
		inkTextRef.SetText( m_Text, text );
	}

	private function OnButtonClick( controller : weak< inkButtonController > )
	{
		SetText( "Button clicked" );
	}

	private function OnButtonHoldComplete( controller : weak< inkButtonController >, cancelled : Bool )
	{
		SetText( "Button hold complete: cancelled? " + cancelled );
	}

	private function OnToggle1Changed( controller : weak< inkToggleController >, isToggled : Bool )
	{
		SetText( "Toggle 1 changed : " + isToggled );
	}

	private function OnToggle1Click( controller : weak< inkButtonController > )
	{
		SetText( "Toggle 1 clicked" );
	}

	private function OnToggle2Changed( controller : weak< inkToggleController >, isToggled : Bool )
	{
		SetText( "Toggle 2 changed : " + isToggled );
	}

	private function OnToggle2Click( controller : weak< inkButtonController > )
	{
		SetText( "Toggle 2 clicked" );
	}

	private function OnToggle3Changed( controller : weak< inkToggleController >, isToggled : Bool )
	{
		SetText( "Toggle 3 changed : " + isToggled );
	}

	private function OnToggle3Click( controller : weak< inkButtonController > )
	{
		SetText( "Toggle 3 clicked" );
	}

	private function OnRadioValueChanged( controller : weak< inkRadioGroupController >, selectedIndex : Int32 )
	{
		SetText( "Radio group selected : " + selectedIndex );
	}

}

