Jump to content
Sign in to follow this  
Ricardo

button click

Recommended Posts

Hi.
If I insert a TW3Button and assign it an event (by double clicking on OnClick in the object inspector) the onClick event is not triggered by clicking with the mouse or with the finger on the mobile. If I set the focus on the button and press Enter it will fire.

I've also tried assigning it to an onclick event in InitializebOject

What do I need to add?

Share this post


Link to post
Share on other sites

Hi.

I have entered the error.
If you declare a FLayout in private and then add this in Resize:


FLayout.Resize (Self);
the buttons can not be pressed with the mouse or with your finger.

Solution:
Add on form Activete:
FLayout: =
    Layout.Client (Layout.Margins (3) .Spacing (3), [
      Layout.Top (W3Label1),
      ...
    ]);
  FLayout.Resize (Self);

and, in Resize
if assigned (FLayout) then
    FLayout.Resize (Self);

I do not know if it is an bug or ignorance on my part.

Share this post


Link to post
Share on other sites

This works for me

unit Form1;

interface

uses 
  System.Types,
  System.Types.Convert,
  System.Objects,
  System.Time,
  SmartCL.System,
  SmartCL.Time,
  SmartCL.Graphics,
  SmartCL.Components,
  SmartCL.FileUtils,
  SmartCL.Forms,
  SmartCL.Fonts,
  SmartCL.Theme,
  SmartCL.Borders,
  SmartCL.Application,
  SmartCL.Layout,
  SmartCL.Controls.Label,
  SmartCL.Controls.Button;

type
  TForm1 = class(TW3Form)
  private
    {$I 'Form1:intf'}
    fLayout: TLayout;
    fLabel: TW3Label;
    fButton: TW3Button;
  protected
   procedure HandleButtonClick(Sender: TObject);
    procedure InitializeForm; override;
    procedure InitializeObject; override;
    procedure Resize; override;
  end;

implementation

{ TForm1 }

procedure TForm1.HandleButtonClick;
begin
 ShowMessage('Click!');
end;

procedure TForm1.InitializeForm;
begin
  inherited;
  // this is a good place to initialize components
end;

procedure TForm1.InitializeObject;
begin
  inherited;
  {$I 'Form1:impl'}

  fLabel:= TW3Label.Create(Self);
  fLabel.Caption:= 'Click Example';
  fLabel.AlignText:= taCenter;

  fButton:= TW3Button.Create(Self);
  fButton.Caption:= 'Click Me';
  fButton.OnClick:= HandleButtonClick;

  fLayout:= Layout.Client([Layout.Top(Layout.Height(32), fLabel), Layout.Bottom(Layout.Height(32), fButton)]);

end;
 
procedure TForm1.Resize;
begin
  inherited;
  if Assigned(fLayout) then
   fLayout.Resize(self);
end;
 
initialization
  Forms.RegisterForm({$I %FILE%}, TForm1);
end.

 

Share this post


Link to post
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.

Sign in to follow this  

×
×
  • Create New...