Event adapter not defined for 'OnSelectedValueChanged' property

In TMS Scripter I added a new component which I can now use in Scripter IDE.

 AIDEEngine.RegisterComponent('Additional', TAdvSmoothSpinner, 'DBCtrls,ComCtrls,StdCtrls,ExtCtrls,Buttons');

It seemed to work well but as soon as I program the Event "OnSelectedValueChanged" I get a scripter error.

procedure ZahlenradSelectedValueChanged(Sender: TObject; Column, SelectedCustomIndex: Integer; SelectedValue: Double; RangeType: TAdvSmoothSpinnerRangeType);
begin
  ;
end;

What can I do?

You have to register the event type in scripter, so the event can be supported. This is indeed not trivial and must be done for each different event type you want to use.

Here are a few previous Support Center topics with explanation and sample code for such process:

I have managed to make it work.
Here my solution (if anyone else has the same problem).
I can use TAdvSmoothSpinner now within the Scripting engine :slight_smile:

...
  AIDEEngine.RegisterComponent('Additional', TAdvSmoothSpinner, 'DBCtrls,ComCtrls,StdCtrls,ExtCtrls,Buttons');
  DefineEventAdapter(TypeInfo(TAdvSmoothSpinnerSelectedValueChangedEvent), TMySelectedValueChangedEventDispatcher,
    @TMySelectedValueChangedEventDispatcher.__TSelectedValueChanged);
...

type
  TMySelectedValueChangedEventDispatcher = class(TatEventDispatcher)
  private
    procedure __TSelectedValueChanged(Sender: TObject; Column, SelectedCustomIndex: Integer; SelectedValue: Double; RangeType: TAdvSmoothSpinnerRangeType);
  end;

procedure TMySelectedValueChangedEventDispatcher.__TSelectedValueChanged(
  Sender: TObject; Column, SelectedCustomIndex: Integer; SelectedValue: Double;
  RangeType: TAdvSmoothSpinnerRangeType);
var
  MyRangeTypeSet: TAdvSmoothSpinnerRangeType;
  MyRangeType: Variant;
begin
  MyRangeTypeSet := RangeType;
  MyRangeType := IntFromSet(MyRangeTypeSet, SizeOf(TAdvSmoothSpinnerRangeType));
  if Assigned(Scripter) and (RoutineName > '') then begin
    Scripter.ExecuteSubroutine(RoutineName, [Sender, Column, SelectedCustomIndex, SelectedValue, MyRangeType]);
  end;
end;
1 Like

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.