{********************************************************************}
{ IntraWeb script editor property editor                             }
{ for Delphi & C++Builder                                            }
{                                                                    }
{ written by : TMS Software                                          }
{               copyright © 2002 - 2010                              }
{               Email : info@tmssoftware.com                         }
{               Web : http://www.tmssoftware.com                     }
{********************************************************************}
unit IWEventScriptEdit;

interface
{$I TMSDEFS.INC}
uses
  Classes, AdvMemo, Dialogs, uEventScriptEdit, Forms, Controls, IWTMSCtrls,
  IWWebGrid, IWTMSCal, IWScriptEvents, IWControl,
{$IFDEF DELPHI6_LVL}
  DesignIntf, DesignEditors
{$ELSE}
  DsgnIntf
{$ENDIF}
  ;

type
  TIWScriptEventsProperty = class(TClassProperty)
  public
    function GetAttributes:TPropertyAttributes; override;
    procedure Edit; override;
  end;

procedure Register;

implementation

uses
  SysUtils;


procedure Register;
begin
  RegisterPropertyEditor(TypeInfo(TIWScriptEvents),TIWCustomControl,'ScriptEvents',TIWScriptEventsProperty);
end;

{ TIWScriptEventProperty }

procedure TIWScriptEventsProperty.Edit;
var
  SE: TTMSEventScriptEdit;

begin
  SE := TTMSEventScriptEdit.Create(Application);

  try
    SE.ScriptEvents.Assign((GetComponent(0) as TIWCustomControl).ScriptEvents);

    if SE.ScriptEvents.Count > 0 then
    begin
      SE.AdvMemo1.Lines.Text := SE.ScriptEvents.Values[SE.ScriptEvents.Items[0].Event];
      SE.ComboBox1.ItemIndex := SE.ComboBox1.Items.IndexOf(SE.ScriptEvents.Items[0].Event);
    end
    else
      SE.AdvMemo1.Lines.Text := SE.ScriptEvents.Values['onAbort'];

    if SE.ShowModal = mrOk then
    begin
      SetOrdValue(longint(SE.ScriptEvents));
    end;
  finally
    SE.Free;
  end;
end;

function TIWScriptEventsProperty.GetAttributes: TPropertyAttributes;
begin
  Result := [paDialog];
end;


end.




