Jump to content
Developer Wiki and Function Reference Links ×

Custom Dialog Boxes


Joe-SA

Recommended Posts

I've written many custom PIO's and various menu commends but have only used the default preset dialog boxes when needed. I'm a total novice when it comes to making my own dialogs from scratch.

What's the best resource to get guides and examples? I've spent a lot of time in the Vectorscript Function Reference but I'm not grasping what I need to know from there.

My need right now is to create a dialog box that finds all the instances of a Record Format in the document, list a check box based on a boolean field in that Record and than label it with other text fields from that same Record. I'd like to be able to toggle each of these fields from one dialog and then either save or cancel at the end.

Pretty simple, I think, I just need something to get me started.

Thanks for the input.

Joe

Link to comment

Joe,

I think I know what you mean, and I think it can be done, but you might need to think about it differently.

A dialog box can't do what you want. A script can. A dialog box (custom or otherwise) is just a way to present the user with an interface to provide input to a script or provide information from a script.

Before you can think about the dialog, you need to figure out how to do all the rest.

By "all instances of f Record Format", do you actually mean all objects with the record attached? Or do you actually mean the Record Format, of which there can only be one of each format in the drawing?

It sounds like you want a variable length dialog box with one row for each object with a record attached and you want to be able to toggle each on or off. Correct?

If so, then getting that data, even the custom labels is pretty easy, For Each Object with a criteria of Record Exists (or something like that). In the handler procedure create an array with a single row for each object. Store the Handle to the object, the current status of the boolean field, and the other text you want to use to label it.

Now, the part you are probably actually asking for help on (and that I have very limited experience with), create the dialog box with the data from the array collected above.

Run the dialog box. If you cancel the dialog box, just quit and don't do anything. If you click OK, then update the array with the current settings of the check boxes.

Loop through the array and write the current boolean status back to each object.

Has this been any help?

Link to comment

Pat,

Maybe I'm showing how novice I am with my phrasing...I was thinking a custom script that created the interfacing dialog box I described. Yes, I want the script to find all the instances of objects attached to a particular format.

I think you understand my intent. I'm seeing the first column of the dialog box being the boolean field where I toggle each instance on or off and save those settings back to each object. The other two columns would be text fields of the same instance of the record format merely providing label information to assist in determining the desired toggle setting.

I haven't scripted an array so your directions I think help me with the next step of the script but you are right, its the creation of the actual dialog box I'm looking to get an example of.

Any example of a similar dialog I can probably manipulate to do what I need.

Thanks for the input.

Joe

Link to comment
  • Vectorworks, Inc Employee

For the dialog portion you can start with Dialog Builder 5.

http://www.vectorworks.net/support/custom/vscript/vstool.php

This will allow you to create the dialog layout. You still need to handle all the operations you want to do and what happens when the user click a button or a check box but this will let you create the dialog you want and get it on the screen.

Link to comment

Kevin (or anyone else),

The part of this that I can't easily wrap my head around is the fact that this could be a dynamic length dialog box. There could be one object with the record or one thousand (maybe not actually, but theoretically).

The (very) little I know about dialog boxes and handlers is that each button/field needs to be handled individually and pretty much hard coded (or maybe not) into the handler.

Is this the kind of thing List Browsers are intended to handle? Can this provide a scrolling "windows" in the dialog box so you don't need a 6-foot high monitor to see all the lines?

Inquiring minds want to know!!

Thanks,

Link to comment
  • Vectorworks, Inc Employee

A list browser or an even simpler list box will allow for a scrolling list. The scroll will appear automatically once the length of the list exceeds the defined height of the dialog control.

You define what's in the list in the dialog handler.

In a list the user can select a single or multiple items and then dialog handler code you create decides what to do with the selected items.

Dialog builder will let you setup the dialog and you can load some sample values with dialog builder to see the dialog creation and setup. You will have to create the code that actually searches the document to find the objects you want.

All the happens in a dialog is that you get notified the the user clicked a button or clicked in a list box, you have to decide what to do when that happens. Sometimes you handle the click right then other times you can wait till the user hits the OK button and then get the values from the dialog.

In some ways a dialog is predefined in other ways it's not. The dialog is created as needed and the creation of control can be defined at run time. If you have 6 objects that match your criteria you could create 6 buttons, if you had 4 only create 4. (The Sheet Border does this sort of thing.)

Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...