Jump to content

New Component


picyka

Recommended Posts

1 hour ago, picyka said:

Tell us the magic, please, you're making a suspense lol

Can you try this approach?

unit uniCheckComboBoxTest;

interface

uses
  Data.DB,
  System.SysUtils,
  System.Classes,
  Vcl.Controls,
  Vcl.Forms,
  uniGUIBaseClasses,
  uniGUIClasses,
  uniMultiItem,
  uniComboBox,
  System.Variants,
  uniGUIApplication,
  Winapi.Windows,
  System.Generics.Collections,
  uniCheckBox, System.StrUtils, uniGUITypes;

type
  TUniCheckComboBoxCustom = class(TUniCheckComboBox)
  private
    { Private declarations }
    //FCheckBox: TUniCheckBox;
    FCheckBoxChecked: Boolean;
    procedure CreateCheckBox;
    procedure SetCheckBoxChecked(const Value: Boolean);
  protected
    { Protected declarations }
    procedure JSEventHandler(AEventName: string; AParams: TUniStrings); override;
    procedure LoadCompleted; override;
  public
    { Public declarations }
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    //property CheckBox: TUniCheckBox read FCheckBox write FCheckBox;
    property CheckBoxChecked: Boolean read FCheckBoxChecked write SetCheckBoxChecked;
  published
    { Published declarations }
  end;

  TUniCheckComboBoxTest = class(TUniCheckComboBoxCustom)
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('UniGUI Extension', [TUniCheckComboBoxTest]);
end;

{ TUniComboBoxObject }

constructor TUniCheckComboBoxCustom.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);

  FCheckBoxChecked := False;

  //if (not (csDesigning in ComponentState)) then
    //Self.CreateCheckBox;
end;

procedure TUniCheckComboBoxCustom.CreateCheckBox;
begin
//  Self.FCheckBox := TUniCheckBox.Create(Self.Owner);
//  Self.FCheckBox.Parent := TWinControl(Self.Owner);
//  Self.FCheckBox.Width := 20;
//  Self.FCheckBox.Caption := '';
//  Self.FCheckBox.Hint := 'Exceto';
//  Self.FCheckBox.ShowHint := True;
end;

destructor TUniCheckComboBoxCustom.Destroy;
begin
  inherited Destroy;
end;

procedure TUniCheckComboBoxCustom.JSEventHandler(AEventName: string;
  AParams: TUniStrings);
begin
  inherited;

  if AEventName = '_checked' then
    FCheckBoxChecked := AParams.Values['checked'] = 'true';

end;

procedure TUniCheckComboBoxCustom.LoadCompleted;
begin
  inherited;
  //Self.FCheckBox.JSInterface.JSCall('alignTo', [Self.JSControl, 'tr?', JSInterface.JSStatement('[-35, 0]')]);
  JSInterface.JSCode(#1'.checkBoxEl = Ext.dom.Helper.insertBefore('#1'.inputEl, {'+
                          'tag: "input", type: "checkbox"'+
                          IfThen(FCheckBoxChecked, ', checked: "checked"', '') +
                          ',onclick: "ajaxRequest('#1', ''_checked'', {checked: this.checked})"'+
                          ',style: "position: absolute; font-size: 1.4em; bottom: 0; right: -3px; top: 1px;"'+
                     '}); '
  )
end;

procedure TUniCheckComboBoxCustom.SetCheckBoxChecked(const Value: Boolean);
begin
  FCheckBoxChecked := Value;
  if not IsLoading then
    JSAssign('checkBoxEl.checked', [FCheckBoxChecked]);
end;

end.

 

Link to comment
Share on other sites

39 minutes ago, Sherzod said:

Can you try this approach?

unit uniCheckComboBoxTest;

interface

uses
  Data.DB,
  System.SysUtils,
  System.Classes,
  Vcl.Controls,
  Vcl.Forms,
  uniGUIBaseClasses,
  uniGUIClasses,
  uniMultiItem,
  uniComboBox,
  System.Variants,
  uniGUIApplication,
  Winapi.Windows,
  System.Generics.Collections,
  uniCheckBox, System.StrUtils, uniGUITypes;

type
  TUniCheckComboBoxCustom = class(TUniCheckComboBox)
  private
    { Private declarations }
    //FCheckBox: TUniCheckBox;
    FCheckBoxChecked: Boolean;
    procedure CreateCheckBox;
    procedure SetCheckBoxChecked(const Value: Boolean);
  protected
    { Protected declarations }
    procedure JSEventHandler(AEventName: string; AParams: TUniStrings); override;
    procedure LoadCompleted; override;
  public
    { Public declarations }
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    //property CheckBox: TUniCheckBox read FCheckBox write FCheckBox;
    property CheckBoxChecked: Boolean read FCheckBoxChecked write SetCheckBoxChecked;
  published
    { Published declarations }
  end;

  TUniCheckComboBoxTest = class(TUniCheckComboBoxCustom)
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('UniGUI Extension', [TUniCheckComboBoxTest]);
end;

{ TUniComboBoxObject }

constructor TUniCheckComboBoxCustom.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);

  FCheckBoxChecked := False;

  //if (not (csDesigning in ComponentState)) then
    //Self.CreateCheckBox;
end;

procedure TUniCheckComboBoxCustom.CreateCheckBox;
begin
//  Self.FCheckBox := TUniCheckBox.Create(Self.Owner);
//  Self.FCheckBox.Parent := TWinControl(Self.Owner);
//  Self.FCheckBox.Width := 20;
//  Self.FCheckBox.Caption := '';
//  Self.FCheckBox.Hint := 'Exceto';
//  Self.FCheckBox.ShowHint := True;
end;

destructor TUniCheckComboBoxCustom.Destroy;
begin
  inherited Destroy;
end;

procedure TUniCheckComboBoxCustom.JSEventHandler(AEventName: string;
  AParams: TUniStrings);
begin
  inherited;

  if AEventName = '_checked' then
    FCheckBoxChecked := AParams.Values['checked'] = 'true';

end;

procedure TUniCheckComboBoxCustom.LoadCompleted;
begin
  inherited;
  //Self.FCheckBox.JSInterface.JSCall('alignTo', [Self.JSControl, 'tr?', JSInterface.JSStatement('[-35, 0]')]);
  JSInterface.JSCode(#1'.checkBoxEl = Ext.dom.Helper.insertBefore('#1'.inputEl, {'+
                          'tag: "input", type: "checkbox"'+
                          IfThen(FCheckBoxChecked, ', checked: "checked"', '') +
                          ',onclick: "ajaxRequest('#1', ''_checked'', {checked: this.checked})"'+
                          ',style: "position: absolute; font-size: 1.4em; bottom: 0; right: -3px; top: 1px;"'+
                     '}); '
  )
end;

procedure TUniCheckComboBoxCustom.SetCheckBoxChecked(const Value: Boolean);
begin
  FCheckBoxChecked := Value;
  if not IsLoading then
    JSAssign('checkBoxEl.checked', [FCheckBoxChecked]);
end;

end.

 

We have the best support in the world here,

 

big hug master

  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...