Jump to content
Developer Wiki and Function Reference Links Read more... ×
EduardoS

Help with Swap Panes

Recommended Posts

Hi all,

I'm testing Swap Panes, just an exercise. I can't manage the panes to swap.

What I am missing or doing wrong?

TIA

 

PROCEDURE EsteScript;
VAR
id :INTEGER;

PROCEDURE Dialog_Setup;
BEGIN
id := CreateLayout('Testando Swap Pane', FALSE, 'OK', 'Cancel');
    
    CreateStaticText(id, 4,'Espaço ou Tamanho?',20);
        SetFirstLayoutItem(id, 4);
    CreatePulldownMenu (id, 5, 17);
        SetBelowItem (id, 4, 5, 0, 0);
    CreateGroupBox (id, 6, 'Os Panes', TRUE);
        SetBelowItem (id, 5, 6, 0, 0);
    CreateSwapControl (id, 7);
        SetFirstGroupItem (id, 6, 7);

    CreateGroupBox (id, 10, 'Pane 1', TRUE);
    CreateStaticText(id, 11,'Espaço',8);
        SetFirstGroupItem (id, 10, 11);

    CreateGroupBox (id, 100, 'Pane 2', TRUE);
    CreateStaticText(id, 101,'Tamanho',8);
        SetFirstGroupItem (id, 100, 101);
        
    CreateSwapPane (id, 7, 10);
    CreateSwapPane (id, 7, 100);
END;

 

PROCEDURE Dialog_Handler (VAR item :LONGINT; data :LONGINT);
VAR
i : INTEGER;
s1 : STRING;
BEGIN
    CASE item OF
        SetupDialogC:
        BEGIN
            AddChoice (id, 5, 'Espaço', 0);
            AddChoice (id, 5, 'Tamanho',0);
        END;
        1:     BEGIN
        END;
        4: BEGIN
            GetSelectedChoiceInfo (id, 5, 0, i, s1);
            DisplaySwapPane (id, 7, 1);
        END;
    END;    
END;
    
BEGIN
    Dialog_Setup;
    IF RunLayoutDialog (id, Dialog_Handler) = 1 THEN BEGIN
    END;
END;
RUN(EsteScript);

Share this post


Link to post

Without digging too much in the code, your case statement uses 4 instead of 5. 

 

You may may want to get in the habit of using constant for dialog item ids. It helps eliminate some errors where you get your ids confused. 

Share this post


Link to post

JBenghiat, after posting this I figured out the 4 instead of 5...

Fixed it, but it still does not swap panes.

Share this post


Link to post

Trying to control the swap panes through Radio Buttons  the same happened, can't manage the panes to swap.

It seams I doing what says in the Vector Works Function Reference.

http://developer.vectorworks.net/index.php/VS:DisplaySwapPane

Any ideas?

Here is what I did:

 

 PROCEDURE EsteScript;

VAR
    EouT :BOOLEAN;
    id :LONGINT;
    
PROCEDURE Dialog_Setup;
BEGIN
id := CreateLayout('Swap Pane Test', FALSE, 'OK', 'Cancel');

    CreateStaticText(id, 4,'Espaço  ou Tamanho?',50);
        SetFirstLayoutItem(id, 4);
        
    CreateGroupBox(id, 10,'RB 1',FALSE);
        SetBelowItem(id, 4, 10, 0, 0);
    CreateRadioButton(id, 11, 'Espaço');
        SetFirstGroupItem(id, 10, 11);
    CreateRadioButton(id, 12, 'Tamanho');
        SetBelowItem(id, 11, 12, 0, 0);
        
    CreateGroupBox(id, 20,'Os Panes',FALSE);
        SetBelowItem(id, 10, 20, 0, 0);
    CreateSwapControl (id, 21);
        SetFirstGroupItem (id, 20, 21);
    
    CreateGroupBox (id, 50, 'Pane E', TRUE);
    CreateStaticText(id, 51,'Espaço',8);
        SetFirstGroupItem (id, 50, 51);

 

    CreateGroupBox (id, 100, 'Pane T', TRUE);
    CreateStaticText(id, 101,'Tamanho',8);
        SetFirstGroupItem (id, 100, 101);

 

    CreateSwapPane (id, 21, 50);
    CreateSwapPane (id, 21, 100);
END;
    
PROCEDURE Dialog_Handler(VAR item :LONGINT; data :LONGINT);
BEGIN
    CASE item OF
        SetupDialogC: BEGIN
            GetBooleanItem(id, 11, EouT);
            IF EouT THEN BEGIN
                DisplaySwapPane (id, 21, 1);
                END
            ELSE BEGIN
                DisplaySwapPane (id, 21, 2);
            END;
        END;
    END;
END;

 

BEGIN
    Dialog_Setup;
    IF RunLayoutDialog (id, Dialog_Handler) = 1 THEN BEGIN
    END;
END;

RUN (EsteScript);

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×