VS:AddChoice

From Vectorworks Developer
Jump to: navigation, search

.VectorScript|VectorScript ..VS:Function Reference|Function Reference ..VS:Function_Reference_Appendix|Appendix

Description

Adds an item to the component's choices.

The valid components are created by CreatePullDownMenu, CreatePullDownMenuGroupBox, CreateListBox, CreateListBoxN.

PROCEDURE AddChoice(
dialogID  :LONGINT;
componentID  :LONGINT;
choiceText  :STRING;
itemIndex  :INTEGER);
def vs.AddChoice(dialogID, componentID, choiceText, itemIndex):
    return None

Parameters

dialogID LONGINT the dialog identifier given by CreateLayout or CreateResizableLayout
componentID LONGINT The identifier for the component that contains the choices.
choiceText STRING The text for the item that is about to be added.
itemIndex INTEGER The index after which the new item is to be added.

Remarks

For components created by CreateEnhancedPullDownMenu, InsertEnhancedPullDownMenuItem should be used.

Example

VectorScript

PROCEDURE AddChoiceSample;
CONST

    { control IDs}
    kCreatePullDownMenu                  = 33;

    kCreatePullDownMenuGroupBox          = 34;

    kCreateListBox                       = 29;
    kCreateListBoxN                      = 30;

    kCreatePushButton                    = 100;

VAR
    dialog            :INTEGER;

PROCEDURE Dialog_Handler(VAR item :LONGINT; data :LONGINT);
BEGIN
    CASE item OF
        SetupDialogC: BEGIN
        
            AddChoice( dialog, kCreatePullDownMenu, 'kCreatePullDownMenu choice', 0 );

            AddChoice( dialog, kCreatePullDownMenuGroupBox, 'kCreatePullDownMenuGroupBox choice', 0 );

            AddChoice( dialog, kCreateListBox, 'kCreateListBox choice', 0 );
            AddChoice( dialog, kCreateListBoxN, 'kCreateListBoxN choice', 0 );

        END;
    END;
END;


BEGIN
    dialog := CreateLayout( 'Add Choice Sample', TRUE, 'OK', 'Cancel' );

    {create controls}

    CreatePullDownMenu( dialog, kCreatePullDownMenu, 24 );

    CreatePullDownMenuGroupBox( dialog, kCreatePullDownMenuGroupBox, 24, 'pull down menu', TRUE );

    CreatePushButton( dialog, kCreatePushButton, 'push button' );
    SetFirstGroupItem( dialog, kCreatePullDownMenuGroupBox, kCreatePushButton );

    CreateListBox( dialog, kCreateListBox, 24, 4 );
    CreateListBoxN( dialog, kCreateListBoxN, 24, 4, TRUE );


    {set relations}
    SetFirstLayoutItem( dialog, kCreatePullDownMenu );
 
    SetBelowItem( dialog, kCreatePullDownMenu, kCreatePullDownMenuGroupBox, 0, 0 );

    SetBelowItem( dialog, kCreatePullDownMenuGroupBox, kCreateListBox, 0, 0 );
    SetBelowItem( dialog, kCreateListBox, kCreateListBoxN, 0, 0 );



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

END;
RUN( AddChoiceSample );

Python

def AddChoiceSample():
	# control IDs
	global kCreatePullDownMenu                
	global kCreatePullDownMenuGroupBox 
	global kCreateListBox                          
	global kCreateListBoxN                        
	global kCreatePushButton   
	global SetupDialogC
	kCreatePullDownMenu                = 33
	kCreatePullDownMenuGroupBox = 34
	kCreateListBox                          = 29
	kCreateListBoxN                        = 30
	kCreatePushButton                    = 100
	SetupDialogC = 12255


def Dialog_Handler(item, data):
	if (item == SetupDialogC):
		vs.AddChoice( dialog, kCreatePullDownMenu, 'kCreatePullDownMenu choice', 0 )
		vs.AddChoice( dialog, kCreatePullDownMenuGroupBox, 'kCreatePullDownMenuGroupBox choice', 0 )
		vs.AddChoice( dialog, kCreateListBox, 'kCreateListBox choice', 0 )
		vs.AddChoice( dialog, kCreateListBoxN, 'kCreateListBoxN choice', 0 )

def CreateMyDialog():
	global dialog
	dialog = vs.CreateLayout( 'Add Choice Sample', 1, 'OK', 'Cancel' )

	#{create controls}

	vs.CreatePullDownMenu( dialog, kCreatePullDownMenu, 24 )

	vs.CreatePullDownMenuGroupBox( dialog, kCreatePullDownMenuGroupBox, 24, 'pull down menu', 1 )

	vs.CreatePushButton( dialog, kCreatePushButton, 'push button' )
	vs.SetFirstGroupItem( dialog, kCreatePullDownMenuGroupBox, kCreatePushButton )

	vs.CreateListBox( dialog, kCreateListBox, 24, 4 )
	vs.CreateListBoxN( dialog, kCreateListBoxN, 24, 4, 1 )


	#{set relations}
	vs.SetFirstLayoutItem( dialog, kCreatePullDownMenu )
 
	vs.SetBelowItem( dialog, kCreatePullDownMenu, kCreatePullDownMenuGroupBox, 0, 0 )

	vs.SetBelowItem( dialog, kCreatePullDownMenuGroupBox, kCreateListBox, 0, 0 )
	vs.SetBelowItem( dialog, kCreateListBox, kCreateListBoxN, 0, 0 )

	if vs.RunLayoutDialog( dialog, Dialog_Handler ) == 1:
		pass

kCreatePullDownMenu = 0               
kCreatePullDownMenuGroupBox  = 0 
kCreateListBox     = 0                       
kCreateListBoxN    = 0                      
kCreatePushButton    = 0 
SetupDialogC = 0 
dialog = 0
AddChoiceSample()
CreateMyDialog()

Version

Availability: from Vectorworks 2010

See Also

For further information, please check out:

CreatePullDownMenu

CreatePullDownMenuGroupBox

CreateListBox

CreateListBoxN

For further information, please check out:

[[VS:CreatePullDownMenu| CreatePullDownMenu]]

[[VS:CreatePullDownMenuGroupBox| CreatePullDownMenuGroupBox]]

[[VS:CreateListBox| CreateListBox]]

[[VS:CreateListBoxN| CreateListBoxN]]
Personal tools
NamespacesFFFF

Variants
Actions
Advanced Search
See Also
Navigation
Toolbox