Rotation and events

I want to turn off rotation all together and add a click event so I change attributes and add a popup menu.


Can you give me an example of how to do this?  

-Scott


Update -  Still can't see how to disable rotation.   I did see that the FNCBloxControl is a container and handles all incoming events such as click doubleclick etc... allowing you access to each element (Block).  I'm still looking for a way to do a popup menu on each block.  Any hints would be appreciated.


-Scott

Update 2:

Figured out how to set the rotation (or remove the ability to rotate).

My Use Case:
Read a directory with small XML files and create a simple rectangle Blox element for each that stores the XML in a class (lets call it ComponentElements and is a Memo object).
Create the ComponentElements class and attach it to the Blox 'Obj' so that each read-in XML is attached to each Blox dropped on the form at runtime.
Doubleclick brings up an XML editor and allows changes to the underlying class XML.
Assign connectors described as 'In' and Out'  Each Blox Element can have several of each depending on the contents of the XML.
Attach via lines from Out-to-In connectors.  Prevent In-to-In and Out-to-Out.
SaveToFile - saving the contents as well as the Obj of ComponentElements attached to each Blox.
LoadFromFIle - reload an existing project.

It almost works.

Problems/bugs?
SaveToFile does not save the Blox rotation attributes set at runtime.
SaveToFile does not save the attached Obj so LoadFromFIle is missing the attached ComponentElements class and contents,  and of coarse the rotation settings.
And as mentioned the add-on menu doesn't build.
Is Blox "End Of Life" ?  I don't want to chase this if it is.

-Scott

Dear Scott,


We have investigated this here and couldn't reproduce the issue with savetofile / loadfromfile, can you send us a specific sample, or test code which is able to reproduce this issue so we can investigate?

Below - a simple VCL form with a panel and buttons.

Build and test by adding blocks and double-click.  Notice the rotate option is correctly gone.  Double click displays the additional CustomElements.

Save

Clear the form

Load

The rotation indicators are back and a doublclick cause an exception due to the CustomElements no longer being valid.

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, VCL.TMSFNCTypes, VCL.TMSFNCUtils,
  VCL.TMSFNCGraphics, VCL.TMSFNCGraphicsTypes, VCL.TMSFNCCustomControl,
  VCL.TMSFNCCustomScrollControl, VCL.TMSFNCBloxControl, VCL.TMSFNCBloxCoreTypes,
  VCL.TMSFNCBloxCoreBlock, VCL.TMSFNCBloxCoreElement,  Vcl.StdCtrls, Vcl.ExtCtrls;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    TMSFNCBloxControl1: TTMSFNCBloxControl;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure TMSFNCBloxControl1ElementDblClick(Sender: TObject;
      Element: TTMSFNCBloxElement);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

type
  TCustomElements = class(TObject)
   NumElements: integer;
   ElementXML: string;
end;


var
  Form1: TForm1;
implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
newblox: TTMSFNCBloxBlock;
CustomElements: TCustomElements;
begin
// For every block we need additional info via Custom Elements;
 CustomElements:= TCustomElements.Create;
 CustomElements.NumElements:= 1;
 CustomElements.ElementXML:= 'Some XML Here';
 newblox:= TTMSFNCBloxBlock.Create;
 newblox.Height:= 50;
 newblox.WIdth:= 75;
 newblox.LinkPoints.Clear;
 //only 2 link points per rectangle on the left and right
 //newblox.LinkPoints.AddLink((Top - Bottom) / 2, Left, aoUp);
 //newblox.LinkPoints.AddLink((Top - Bottom) / 2, Right, aoUp);
 newblox.Restrictions:= [crNoRotation];
 newblox.Obj:= CustomElements; // Lets attach each CustomElements to its Blox
 TMSFNCBloxControl1.Blox.Add(newblox);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
 TMSFNCBloxControl1.SaveToFile('c:\temp\blox.data');
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
 TMSFNCBloxControl1.Blox.Clear;
 TMSFNCBloxControl1.LoadFromFile('c:\temp\blox.data');
end;

procedure TForm1.TMSFNCBloxControl1ElementDblClick(Sender: TObject;
  Element: TTMSFNCBloxElement);
begin
  ShowMessage((Element.Obj as TCustomElements).ElementXML);
end;

end.



-Scott

A folowup note:  I'm using the Demo so I can't debug to try and figure out the correct way to attach objects to the Elements for saving.


Also building and Installing the TTMSFNCBloxToolBar component on page 18 of the Developers guide fails.  However I noticed the instructions are not specifically for Rio 10.3.1

-Scott

Hi,


We have taken a look at the code, but unfortunately a custom object will not be saved to a file, because its a pointer to an object, and not a published property. Also, obj is a public property, not a published property and thus not saved. You can only save a custom object, if it is a published property of the blox object, so you should inherit from the blox type of choice, exposing a published property of type TCustomElements.

OK and what about newblox.Restrictions:= [crNoRotation];

Its not persistent from save to load.

-Scott

You have created a TTMSFNCBloxBlock which doesn't have Restrictions as a published property. Please choose a different base type, such as TTMSFNCBloxTextBlock or TTMSFNCBloxImageBlock to persist properties such as Restrictions.