Adding checkbox buttons from script
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Adding checkbox buttons from script
Hi,
I want to add checkbox buttons based on the numbers of columns in a file. I have a button to import a file, and based on the contents of that file, I want to be able to create, say, 15 checkbox buttons with the titles reflecting information from the file. Note that the # of buttons I need and the titles of those buttons will change with each new file I import.
Can you add checkbox buttons from the script? Or do you have to put them there in developer mode?
If you cannot add them from the script, is it possible to add a bunch of buttons at the beginning and then change the titles later from the script?
I want to add checkbox buttons based on the numbers of columns in a file. I have a button to import a file, and based on the contents of that file, I want to be able to create, say, 15 checkbox buttons with the titles reflecting information from the file. Note that the # of buttons I need and the titles of those buttons will change with each new file I import.
Can you add checkbox buttons from the script? Or do you have to put them there in developer mode?
If you cannot add them from the script, is it possible to add a bunch of buttons at the beginning and then change the titles later from the script?
-
- VIP Livecode Opensource Backer
- Posts: 9579
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Adding checkbox buttons from script
Hi.
LC can do anything you can think of. Check out the "create" command in the dictionary.
In your script, you would (pseudo)
Craig Newman
LC can do anything you can think of. Check out the "create" command in the dictionary.
In your script, you would (pseudo)
Code: Select all
create button
set the style of last button to "checkBox"
set the loc of last button to wherever
set all other properties you are interested in
Re: Adding checkbox buttons from script
Yes, you can.
Things to check in the dictionary:
Things to check in the dictionary:
- "button" for all the button properties that you can set
- "style" is the property that controls the type of button (rectangle, checkbox, etc.)
- "templateButton". You can preset all the properties that you want all your checkboxes to share, before you create them
Re: Adding checkbox buttons from script
Thank you both.
I can create the buttons now, but I am trying to have them appear in a column within a text field.
Is it possible to take a set of text lines, and using a repeat function, transform a text line into a checkbox button? This would work better for my purposes.
Basically, I have this in a text field:
It's organized the way I want. I want to first populate the text field with all the info I want, and then transform those text lines into checkbox buttons. Is that possible?
I can create the buttons now, but I am trying to have them appear in a column within a text field.
Is it possible to take a set of text lines, and using a repeat function, transform a text line into a checkbox button? This would work better for my purposes.
Basically, I have this in a text field:
Code: Select all
Username
ID
ExperimentName
Session
Trial
Date
Re: Adding checkbox buttons from script
You could with a datagrid. That would also give you a scroller, without having to build everything.
Re: Adding checkbox buttons from script
Just looking at a data grid and it seems like exactly what I want! Thank you!
Once I import the data into the grid, is there anything special to turn the row into a checkbox? Or can you make just the first column a checkbox, and the other columns pure data. That might be good for my purposes, actually.
Anyways, thank you!
Once I import the data into the grid, is there anything special to turn the row into a checkbox? Or can you make just the first column a checkbox, and the other columns pure data. That might be good for my purposes, actually.
Anyways, thank you!
Re: Adding checkbox buttons from script
I would go even simpler than that and just use the first column as a text field and control it so that it either has an “X” or is blank.
Re: Adding checkbox buttons from script
I have created a data grid with two columns, but I cannot figure out how to make the first column a text column (or a checkbox):
- Attachments
-
- datagrid.JPG (25.21 KiB) Viewed 6084 times
Re: Adding checkbox buttons from script
It should already be a text column. Now refer to the DataGrid manual. You can either respond to a click on a row, or a click in the "Selected" column on a row (I prefer to respond to a click anywhere on a row, but that's just my preference). When someone clicks on a row in that column, the value of the cell should toggle between "X" and empty.
-
- VIP Livecode Opensource Backer
- Posts: 9579
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Adding checkbox buttons from script
If you use a DG for your purposes , you will likely need to use the "form" variant, as opposed to the more basic "table" type.
DG's, especially forms, require a learning and practicing curve. They work right out of the box, but to customize them takes time.
It is time well spent, as they are powerful tools once you become even moderately proficient.Check out the lessons and the DG manual, as Mikey suggested.
Craig Newman
DG's, especially forms, require a learning and practicing curve. They work right out of the box, but to customize them takes time.
It is time well spent, as they are powerful tools once you become even moderately proficient.Check out the lessons and the DG manual, as Mikey suggested.
Craig Newman
Re: Adding checkbox buttons from script
I don't think in this case form is necessary since you can fake checkbox behavior, but if it isn't good enough, then I agree, form