WhoCanDo Posted August 30, 2019 Share Posted August 30, 2019 Hi, Where do you put AddChoice to load CreatePullDownMenu? If I put it here, while Creating the Dialog layout, it doesn't work.. procedure CreateDialog1Layout; begin StanDialog1 := CreateLayout ('Handrail ID', False, 'OK', 'Cancel'); AddChoice (StanDialog1, 7, ' ', 0); AddChoice (StanDialog1, 7, 'R', 1); AddChoice (StanDialog1, 7, 'L', 2); If I put it here, after Creating the Dialog layout, it doesn't work.. CreateDialog1Layout; AddChoice (StanDialog1, 7, ' ', 0); AddChoice (StanDialog1, 7, 'R', 1); AddChoice (StanDialog1, 7, 'L', 2); If (RunLayoutDialogN (StanDialog1, GetCodeDialog1Results, True) = 1 { OK }) then If I put it here, it duplicates the list repeatedly while picking or filling in other Edit boxes.. procedure GetDialog1Results (var Item : longint; Data : longint); begin AddChoice (StanDialog1, 7, ' ', 0); AddChoice (StanDialog1, 7, 'R', 1); AddChoice (StanDialog1, 7, 'L', 2); Case Item of SetupDialogC: GetDialog1Events; Quote Link to comment
JBenghiat Posted August 30, 2019 Share Posted August 30, 2019 You want it in your dialog handler, GetDialog1Results (which is a bit of a misleading name, as this procedure runs every time you have a dialog event). You generally initialize a pulldown in the SetupDialogC case, which is an event that runs before the dialog displays. Otherwise item will correspond to the selected control. You can also dynamically add and remove items during any event, for example if the selection of one pulldown affects another, like record / field. Quote Link to comment
WhoCanDo Posted August 30, 2019 Author Share Posted August 30, 2019 The old Dialog method was easier to understand, but harder to setup, than the new, so I've not completely grasped the process yet. This is how I have formatted mine, so where to you put AddChoice? 1. Set up Dialog layout. 2. Get Dialog results. procedure GetEvents; begin GetItemText (StanDialog1, 5, Code); end; begin SetupDialog; Case Item of SetupDialogC: GetEvents; 1 : GetCodeDialog1Events; 2 : ; { Cancel } end; { Case } end; 3. Do something with the results Quote Link to comment
JBenghiat Posted August 30, 2019 Share Posted August 30, 2019 I can't quite follow your code. The way you're using GetEvents, SetupDialogC, and GetCodeDialog1Events seems wrong, but I can't tell without the actual code. This example has the full code structure for a dialog and includes a pulldown: http://developer.vectorworks.net/index.php/VS:CreateLayout Quote Link to comment
WhoCanDo Posted August 30, 2019 Author Share Posted August 30, 2019 In the example, where does GetItemText (StanDialog1, 5, Code); etc. happen? How do you get the events/results? I have been shown to create a sub-procedure GetDialogEvents to Dialog_Handler and use it as follows. Case Item of SetupDialogC: GetDialogEvents; 1 : GetDialogEvents; { OK } 2 : ; { Cancel } end; { Case } Quote Link to comment
WhoCanDo Posted August 30, 2019 Author Share Posted August 30, 2019 Got it. So my code should be procedure AddChoices; begin end; procedure GetDialogEvents; begin end; Case Item of SetupDialogC: begin AddChoices; end; 1 : GetDialogEvents; 2 : ; { Cancel } end; { Case } Quote Link to comment
JBenghiat Posted August 30, 2019 Share Posted August 30, 2019 Forgive me if I'm over-explaining, but the your formatting is a little confusing, so I thought breaking down the handler might be of assistance. This is how I would format those statements: Case Item of SetupDialogC: AddChoices; 1: {ID of ok button} GetDialogEvents; 2: { ID of Cancel button } end; { Case } Item is generally the id of the item the user interacts with, but the dialog will also raise a setup id before the dialog displays and a set-down id after the dialog closes. Setup / Set-down are also where you might get / set any saved settings for dialog position or values. The case statement is just a condensed if/then syntax. In your code, if the dialog is in setup, run AddChoices. If the user clicks OK, (presumable) save dialog values to global variables. Do nothin if the user clicks cancel. Each response in the case statement does not need to be a separate procedure, though it can be if the code is more clear to you. Functionally, it is the same as Begin {procedure code} End; 1 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.