Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Custom control inherited from IWControls

I´m developing some IWControls inherited from TIWEdit.

I would like to ask for help, since I´m having a few problems with the inherited controls in design time.

I must say that I´m using IW 14 bundled version (delphi 10.3), so no access to the source code avaiable.

1# - Inherited controls doesn´t look like their parents in design time. (see picture attached). (solved, see the post bellow)
2# - Not possible to assign ScriptAvents through a method called by other property setter.

There is a boolean property, and based on it´s value a method gets some javascripts in order to be set at scriptevents.
The boolean property setter, after defining the property value, calls the method to add the script events.
The method is being called properly, but before adding the new scripts, is necessery to delete the old ones.
If the old scriptevents are not deleted, the new one is not added.

So, the SetJavaScripts method, looks like this:

procedure TLBIWXEditFloat.SetJavaScripts(aAllowNegative: boolean);
  _Idx: Integer;
  _OnKeyDown: TStringList;
  _Idx := Self.ScriptEvents.IndexOf('onKeyDown');

  if _Idx > 0 then

_OnKeyDown := TLBXIntraWebJs.GetScrptEdtFloatOnKeyDown(aAllowNegative);
    Self.ScriptEvents.Add('onKeyDown', _OnKeyDown.Text);

The problem is that in design time, "Self.ScriptEvents.IndexOf('onKeyDown')" always returns -1, therefore is impossible to delete the scriptevent, preventing to add the new one.

AllowNegative setter looks like this:

procedure TLBIWXEditFloat.SetAllowNegative(const Value: Boolean);


  FAllowNegative := Value;


What am I missing?

Thanx in advance!
After talking to chad at support chat, I´ve managed to solve the first problem. (1# - Inherited controls doesn´t look like their parents in design time. (see picture attached).)

I had to mark the package with the descendent controls as Only Runtime, created another package Only Designtime, and to register the painters for the controls.

Like this:

  IWRegisterPaintHandler('TLBIWXEdit', TIWPaintHandlerEdit);

Also, moved the register procedure to the design time package.
As I responded in the portuguese channel, don't use the TOwnedCollection (TIWScriptEvents ancestor) methods.

TIWScriptEvents have specific methods to handle adding/updating code:

TIWScriptEvents.HookEvent(const AEventName: string; AEventCode: string);

HookEvent will add a new event or update existing event using the provided code.

Forum Jump:

Users browsing this thread: 1 Guest(s)