How do I rotate a control by X degrees?

All descendants of TW3Customcontrol, which is the primary object most visual controls derive from, has a property called Angle. This is a floating point property which will rotate your control in whatever angle you define. Please bear in mind that this property will override any webkit rotation in the current style. If you want the stylesheet to retain it’s position, mark the CSS tag with !important;

For instance:

unit Form1;

interface

uses w3system, w3ctrls, w3forms, w3application;

type
TForm1=class(TW3form)
private
 { Private methods }
 FButton: TW3Button;
 Procedure  HandleClick(Sender:TObject);
protected
  { Protected methods }
  Procedure InitializeObject;override;
  Procedure FinalizeObject;override;
  Procedure StyleTagObject;override;
end;

Implementation

//############################################################################
// TForm1
//############################################################################

Procedure TForm1.InitializeObject;
Begin
  inherited;
  FButton:=TW3Button.Create(self);
  FButton.caption:='Click me';
  FButton.setBounds(100,50,100,28);
  FButton.onClick:=HandleClick;
End;

Procedure TForm1.HandleClick(Sender:TObject);
Begin
  if FButton.Angle=60 then
  FButton.Angle:=0 else
  FButton.Angle:=60;
end;

Procedure TForm1.FinalizeObject;
Begin
  inherited;
End;

Procedure TForm1.StyleTagObject;
Begin
  inherited;
  StyleClass:='TW3CustomForm';
End;

end.

When you click the button it will toggle between normal (0 deg) and tilted (60 deg), like this:

Best not to over do it

Best not to over do it

You must be logged in to post a comment.